linux-gunicorn在启动后无法启动

我正在用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

相关文章

文章浏览阅读3.7k次,点赞2次,收藏5次。Nginx学习笔记一、N...
文章浏览阅读1.7w次,点赞14次,收藏61次。我们在使用容器的...
文章浏览阅读1.4k次。当用户在访问网站的过程中遇到404错误时...
文章浏览阅读2.7k次。docker 和 docker-compose 部署 nginx+...
文章浏览阅读1.3k次。5:再次启动nginx,可以正常启动,可以...
文章浏览阅读3.1w次,点赞105次,收藏182次。高性能:Nginx ...