【发布时间】:2020-10-06 15:33:16
【问题描述】:
我在/etc/systemd/system/gunicorn.service 有以下systemd 文件
[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target
[Service]
WorkingDirectory=/home/serverapp
ExecStart=gunicorn --name=avesoft --bind unix:/home/serverapp/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py WebApp.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=root
Group=www-data
[Install]
WantedBy=multi-user.target
当我手动将目录更改为 /home/serverapp 并运行 gunicorn --name=avesoft --bind unix:/home/serverapp/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py WebApp.wsgi:application 时,一切正常,Nginx 通过 Gunicorn 连接到我的 Django 应用程序。
但是通过重新启动服务器,我收到 Bad Gateway 错误,似乎 Gunicorn 尚未开始工作。我不明白我的服务文件不起作用的原因是什么。
【问题讨论】:
-
当你
sudo systemctl start gunicorn时它是否有效? -
@Mohd 不,它会引发此错误:
Reason: Exec format error)
标签: django linux nginx server digital-ocean