[英]gunicorn does not start after boot
我正在運行 Debian web 服務器和 nginx 以及運行 django 應用程序的 gunicorn。 我已經啟動並運行得很好,但在重新啟動服務器后,我收到 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
完美,我在重啟后遇到了同樣的問題,gunicorn 沒有激活。 你救了我的命 兄弟
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.