在文件夹中使用WSGI运行Gunicorn

问题描述

我的项目结构如下。我使用文件夹将所有设置文件放入其中。

~/myproject/
           - env
           - server
                 - api
                 - home
                     - settings
                         - dev.py
                         - prod.py
                     - wsgi
                         - dev.py
                         - prod.py

myproject / server / home / wsgi / dev.py是:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE","home.settings.dev")

application = get_wsgi_application()
在myproject / server / home / settings / dev.py中的

也是:

WSGI_APPLICATION = 'home.wsgi.dev.application'

使用上述所有设置,服务器均可正常运行。当我尝试部署并运行Gunicorn时,它只是失败了。这是我的gunicorn.service:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=demouser
Group=www-data
WorkingDirectory=/home/demouser/myproject
ExecStart=/home/demouser/myproject/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/demouser/myproject.sock home.wsgi.dev:application


[Install]
WantedBy=multi-user.target

我不确定为什么会出现此错误,因为枪支永远不会启动:

 Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-08-30 05:04:48 UTC; 14min ago
  Process: 13354 ExecStart=/home/demouser/myproject/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/
 Main PID: 13354 (code=exited,status=203/EXEC)

Aug 30 05:04:48 localhost systemd[1]: Started gunicorn daemon.
Aug 30 05:04:48 localhost systemd[13354]: gunicorn.service: Failed to execute command: No such file or directory
Aug 30 05:04:48 localhost systemd[13354]: gunicorn.service: Failed at step EXEC spawning /home/demouser/myproject/env/
Aug 30 05:04:48 localhost systemd[1]: gunicorn.service: Main process exited,code=exited,status=203/EXEC
Aug 30 05:04:48 localhost systemd[1]: gunicorn.service: Failed with result 'exit-code'.
~

我希望我对所有人都说清楚了。谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)