【问题标题】:wsgi directory in gunicorn service file not recognisedgunicorn 服务文件中的 wsgi 目录无法识别
【发布时间】:2021-10-10 11:05:40
【问题描述】:

我需要一些帮助来解决这个问题。 gunicorn 中的 myproject.wsgi 无法识别。 我创建了一个具有 sudo 权限的用户 flolog。我的项目结构如下(我创建的第一个目录是flo-log,它包含d django app中的其他目录):

:~/
    flo-log/
        account/
        logistics/
            settings.py
            wsgi.py
            ...
        manage.py
        ...
    flologenv/
    requirements.txt

gunicorn 文件内容为:

我该如何解决?或者有什么资源可以提供帮助?

【问题讨论】:

    标签: django postgresql nginx gunicorn digital-ocean


    【解决方案1】:

    如果没有您的项目结构,很难定义问题,但在我看来,您在工作目录中给出了 app 文件夹的路径,而不是根文件夹的路径。这是我的设置,可以帮助您配置 wsgi。 "conf" 是带有设置和 asgi wsgi 文件的应用程序的名称。

    sudo vim /etc/systemd/system/gunicorn.sock
    
    [Unit]
    Description=Gunicorn daemon for Django Project
    Before=nginx.service
    After=network.target
    
    [Service]
    WorkingDirectory=/home/www/app/root_folder
    ExecStart=/home/www/app/venv/bin/gunicorn --access-logfile - --workers 3 --log-level debug --bind unix:/home/www/app/root_folder/conf.sock conf.wsgi:application
    Restart=always
    SyslogIdentifier=gunicorn
    User=root
    Group=www-data
    
    
    [Install]
    WantedBy=multi-user.target
    

    【讨论】:

    • 非常感谢@Aptem。我还没有找到一个可行的解决方案,我已经尝试根据您的评论更新我的代码,但主要问题仍然存在。我已更新我的问题以包括我的项目结构。
    • 尝试将您的工作目录更改为“/home/flolog/flo-log”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多