我正在用Nginx和Gunicorn运行django应用程序的Debian Web服务器.我一切正常,运行正常,但重新启动服务器后,出现502错误的网关错误.我将问题追溯到重新启动后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服务?
编辑:
问题可能是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
最佳答案
原文链接:https://www.f2er.com/nginx/532339.html