簡體   English   中英

Gunicorn 未開始拋出 gunicorn.service:失敗,結果為“退出代碼”。 錯誤

[英]Gunicorn not starting throwing gunicorn.service: Failed with result 'exit-code'. error

我正在嘗試按照此鏈接在 DigitalOcean 上部署簡單的 Django 應用程序跟隨錯誤

gunicorn.service:失敗,結果為“退出代碼”。

這是我的以下配置

須藤納米 /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

須藤納米 /etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=pos
Group=www-data
WorkingDirectory=/home/pos/pos
ExecStart=/home/pos/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          pos.wsgi:application

[Install]
WantedBy=multi-user.target

須藤 systemctl 狀態 gunicorn.socket

● gunicorn.socket - gunicorn socket
   Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Tue 2019-11-26 07:39:39 UTC; 12min ago
   Listen: /run/gunicorn.sock (Stream)
   CGroup: /system.slice/gunicorn.socket

Nov 26 07:39:39 POS systemd[1]: Listening on gunicorn socket.

當我嘗試啟動 gunicorn 時,它拋出了這個錯誤

sudo systemctl 狀態 gunicorn

● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-11-26 07:39:43 UTC; 13min ago
  Process: 718 ExecStart=/home/pos/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock pos.wsgi:application (code=exited, status=1/FAILURE)
 Main PID: 718 (code=exited, status=1/FAILURE)
Nov 26 07:39:43 POS gunicorn[718]:     Arbiter(self).run()
Nov 26 07:39:43 POS gunicorn[718]:   File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 198, in run
Nov 26 07:39:43 POS gunicorn[718]:     self.start()
Nov 26 07:39:43 POS gunicorn[718]:   File "/home/pos/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 155, in start
Nov 26 07:39:43 POS gunicorn[718]:     self.LISTENERS = sock.create_sockets(self.cfg, self.log, fds)
Nov 26 07:39:43 POS gunicorn[718]:   File "/home/pos/env/lib/python3.7/site-packages/gunicorn/sock.py", line 172, in create_sockets
Nov 26 07:39:43 POS gunicorn[718]:     sock_name = sock.getsockname()
Nov 26 07:39:43 POS gunicorn[718]: OSError: getsockaddrlen: bad family
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Nov 26 07:39:43 POS systemd[1]: gunicorn.service: Failed with result 'exit-code'.

有人幫我解決這個問題嗎?

最新版本的gunicorn(20.0.3)會導致這個問題

嘗試安裝舊版本的 gunicorn:

pip install gunicorn==20.0.2

似乎您正在嘗試在ExecStart收聽unix:/run/gunicorn.sock ExecStart ,但套接字位於run/gunicorn.socket 嘗試更改此設置並運行systemctl daemon-reload以查看它是否有所不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM