gpt4 book ai didi

linux - gunicorn 开机后不启动

转载 作者:IT王子 更新时间:2023-10-29 01:20:20 29 4
gpt4 key购买 nike

我正在运行一个带有 nginx 的 Debian 网络服务器,而 gunicorn 运行一个 django 应用程序。我已经启动并运行得很好,但在重新启动服务器后,我收到 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

关于linux - gunicorn 开机后不启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43857549/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com