Ant*_*ntu 4 django ubuntu nginx gunicorn server
我按照这个试穿DigitalOcean一个简单的部署Django应用程序的链接我按照每工作一步步成功运行通过Python manage.py的runserver项目中它不扔任何错误,但是当我尝试gunicorn其扔来实现它跟随错误
gunicorn.service:失败,结果为“退出代码”。
这是我的以下配置
须藤纳米 /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
Run Code Online (Sandbox Code Playgroud)
须藤纳米 /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
Run Code Online (Sandbox Code Playgroud)
须藤 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.
Run Code Online (Sandbox Code Playgroud)
当我尝试启动 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'.
Run Code Online (Sandbox Code Playgroud)
有人帮我解决这个问题吗?
小智 6
最新版本的gunicorn(20.0.3)会导致这个问题。
尝试安装旧版本的 gunicorn:
pip install gunicorn==20.0.2
Run Code Online (Sandbox Code Playgroud)
小智 5
看来您正在尝试侦听unix:/run/gunicorn.sockin ExecStart,但套接字位于run/gunicorn.socket。尝试更改此设置并运行,systemctl daemon-reload看看是否会有所不同。
| 归档时间: |
|
| 查看次数: |
7810 次 |
| 最近记录: |