我正在尝试在Digital Ocean上部署一个简单的Django应用程序,方法是:[link][1]我一步一步地执行每项工作,并通过python www.example.com runserver成功地运行了该项目manage.py,它没有抛出任何错误,但当我尝试用gunicorn实现它时,它抛出了以下错误
gunicorn.service:失败,结果为“exit-code”。
下面是我的配置:
sudo nano /etc/系统管理程序/系统/枪角.套接字
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /等/系统/系统/gunicorn.服务
[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
sudo systemctl状态命令.套接字
● 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系统状态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'.
有人能帮我解决这个问题吗?[1]:https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
3条答案
按热度按时间wko9yo5t1#
最新版本的gunicorn(20.0.3)可能导致此problem。
尝试安装较旧版本的gunicorn:
2uluyalo2#
您似乎试图在
ExecStart
中侦听unix:/run/gunicorn.sock
,但套接字位于run/gunicorn.socket
。请尝试更改此设置并运行systemctl daemon-reload
,看看是否会产生影响。qni6mghb3#
工作目录=/home/sammy/我的项目目录/我的项目/