gunicorn守护程序(活动:失败)/ curl(56)接收失败:对等方重置连接

问题描述 投票:0回答:1

[第一件事,我不确定这是在这里还是在Ubuntu上询问是否更好(Ubuntu没有'gunicorn'标签,所以我认为我来对了地方)。如果不合适,请在评论中添加,然后将其关闭。

我正在跟踪关于部署的Digitalocean教程(https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04).I取决于gunicorn的设置。我竭尽全力地尝试使此gunicorn正常工作,所以我来了这里。引号中的任何内容都是失败之前,我开始进行“检查Gunicorn套接字文件”和“检查/ run目录中是否存在gunicorn.sock文件:”。检查套接字文件:

  sudo systemctl status gunicorn.socket returns
    Failed to dump process list, ignoring: No such file or directory
    ● gunicorn.socket - gunicorn socket
       Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor pres
       Active: active (listening) since Fri 2020-02-21 21:34:06 UTC; 1min 8s ago
       Listen: /run/gunicorn.sock (Stream)
       CGroup: /system.slice/gunicorn.socket

检查gunicorn.sock的存在:

file /run/gunicorn.sock

输出:/run/gunicorn.sock: socket

“在测试套接字激活时,它失败:

sudo systemctl status gunicorn

输出:

● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service;
   Active: failed (Result: exit-code) since Fri 2020-02-
 Main PID: 15708 (code=exited, status=217/USER)

Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: S
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[15708
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[15708
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: F
lines 1-13/13 (END)

它说要测试套接字激活,请执行以下操作:

curl --unix-socket /run/gunicorn.sock localhost

输出(说我应该看HTML):

curl: (56) Recv failure: Connection reset by peer

不确定我是否提供了足够的信息。下面将包括我的gunicorn.socketgunicorn.service文件以及服务器上目录的布局。

gunicorn.socket:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

gunicorn.service:

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

[Service]
User=justin
Group=www-data
WorkingDirectory=/home/justin/project
ExecStart=/home/justin/project/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          jobzumo.wsgi:application
[Install]
WantedBy=multi-user.target

服务器/项目的布局:

home/justin/project/

project/文件夹包含envenv/bin/gunicorn确实存在),jobzumo(django项目),manage.pystatic

[我唯一想的是,我可能在使用root时创建了这些gunicorn文件,现在我正在尝试使用用户justin对其进行修改?不太确定这是怎么回事。如果我没有提供足够的信息,或者如果您需要我运行任何类型的调试命令,请告诉我。感谢您的帮助。

gunicorn systemd
1个回答
0
投票

我必须运行以下两个命令:

sudo ufw delete allow 8000
sudo ufw allow 'Nginx Full'

现在一切正常。显然,这会将防火墙打开到端口80。由于我未在其中指定端口80,所以不确定为什么,但是它可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.