【发布时间】:2020-08-30 20:27:08
【问题描述】:
我的项目结构如下。我使用文件夹将所有设置文件放入其中。
~/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
我不确定为什么我会收到此错误,因为 gunicorn 永远不会启动:
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'.
~
我希望我为每个人都说清楚了。谢谢
【问题讨论】: