加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

linux-gunicorn在启动后无法启动

发布时间:2020-12-13 20:56:04 所属栏目:Nginx 来源:网络整理
导读:我正在用Nginx和Gunicorn运行django应用程序的Debian Web服务器.我一切正常,运行正常,但重新启动服务器后,出现502错误的网关错误.我将问题追溯到重新启动后gunicorn处于非活动状态.如果我启动该服务,问题将得到解决,直到我再次重新启动服务器. 启动服务: sy

我正在用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
最佳答案
您的gunicorn.service文件中有一个小的错字.改成:

WantedBy=multi-user.target

另外,您可能需要更改为:

Restart=always

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读