我正在运行 Debian Web 服务器,其中 nginx 和 Gunicorn 运行 django 应用程序。我已经一切正常并运行良好,但重新启动服务器后,我收到 502 bad gateway 错误。我已将问题追溯到gunicorn 在重新启动后处于非活动状态。如果我启动该服务,问题就会得到解决,直到我再次重新启动服务器。
启动服务:
systemctl start gunicorn.service
重启后这是我的gunicorn服务状态:
{username}@instance-3:~$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled)
Active: inactive (dead)
我的 /etc/systemd/system/gunicorn.service 文件的内容:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User={username}
Group={username}
WorkingDirectory=/home/{username}/web/{projname}
ExecStart=/usr/local/bin/gunicorn {projname}.wsgi:application
Restart=on-failure
[Install]
WantedBy=multi.user.target
有什么想法可以弄清楚为什么gunicorn服务在重新启动后没有启动吗?
Edit:
问题可能是gunicorn.conf 在 chdir 和 exec 中的目录与工作目录不同吗?
{username}@instance-3:~$ cat /etc/init/gunicorn.conf
cription "Gunicorn application server handling {projname}"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid {username}
setgid {username}
chdir /home/data-reporting/draco_reporting
exec {projname}/bin/gunicorn --workers 3 --bind unix:/home/{username}/data-reporting/{projname}/{projname}.sock {projname}.wsgi:application
你的有一个小错字gunicorn.service
文件。改成:
WantedBy=multi-user.target
另外,您可能想更改为:
Restart=always
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)