简体   繁体   English

无法启动 gunicorn.service:gunicorn.socket 的作业失败。 乌本托 18.04

[英]Failed to start gunicorn.service: Job for gunicorn.socket failed . Ubunto 18.04

I am following this How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04 guide.我正在关注如何在 Ubuntu 18.04 指南中使用 Postgres、Nginx 和 Gunicorn 设置 Django。

I have created the following file.socket我创建了以下 file.socket

sudo nano /etc/systemd/system/gunicorn.socket



[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

I have created the following file.service.我创建了以下 file.service。 How I have formatted my own version我如何格式化自己的版本

sudo nano /etc/systemd/system/gunicorn.service

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

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

[Install]
WantedBy=multi-user.target

Than I have tried to execute the following code比我尝试执行以下代码

sudo systemctl start gunicorn.socket

And i have recibed this message error我已经收到了这个消息错误

Job for gunicorn.socket failed
See "systemctl status gunicorn.socket" and "journalctl -xe" for details. 

After i tried the recommended code在我尝试了推荐的代码之后

● gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: inactive (dead)
Listen: /run/gunicorn.sock (Stream)

Apr 26 18:41:45 projetoagenda systemd[1]: gunicorn.socket: Socket service gunicorn.service not 
loaded, refusing.
Apr 26 18:41:45 projetoagenda systemd[1]: Failed to listen on gunicorn socket.
Apr 26 18:48:41 projetoagenda systemd[1]: gunicorn.socket: Socket service gunicorn.service not 
loaded, refusing.
Apr 26 18:48:41 projetoagenda systemd[1]: Failed to listen on gunicorn socket.
Apr 26 18:52:53 projetoagenda systemd[1]: gunicorn.socket: Socket service gunicorn.service not 
loaded, refusing.
Apr 26 18:52:53 projetoagenda systemd[1]: Failed to listen on gunicorn socket.
Apr 26 18:53:27 projetoagenda systemd[1]: gunicorn.socket: Socket service gunicorn.service not 
loaded, refusing.
Apr 26 18:53:27 projetoagenda systemd[1]: Failed to listen on gunicorn socket.
Apr 26 19:02:09 projetoagenda systemd[1]: gunicorn.socket: Socket service gunicorn.service not 
loaded, refusing.
Apr 26 19:02:09 projetoagenda systemd[1]: Failed to listen on gunicorn socket.

i have followed this sugetions but nothing happen Failed to start gunicorn.service: Unit gunicorn.service not found.我已经遵循了这个 sugetions 但没有任何反应无法启动 gunicorn.service:未找到 Unit gunicorn.service。 Ubunto 18.04 乌本托 18.04

sorry for this question, it´s my firts time asking help in english.对不起这个问题,这是我第一次用英语寻求帮助。

I had the same issue and it was also returning the same error.我遇到了同样的问题,它也返回了同样的错误。 I managed to fix it for myself so I decided to share what I did, perhaps someone finds it useful too:我设法为自己修复了它,所以我决定分享我所做的,也许有人觉得它也很有用:

Fix: First I ran command: sudo systemctl enable gunicorn.socket (it created symlink) Then I tried running: sudo systemctl start gunicorn.socket - but it returned that the job for gunicorn socket failed, however, I ran sudo systemctl enable gunicorn.socket again and then sudo systemctl start gunicorn.socket and the issue was no more and upon checking status ( command sudo systemctl status gunicorn.socket ) it finally returned that it is active (listening).修复:首先我运行命令: sudo systemctl enable gunicorn.socket (它创建了符号链接)然后我尝试运行: sudo systemctl start gunicorn.socket - 但它返回 gunicorn 套接字的作业失败,但是,我运行了sudo systemctl enable gunicorn.socket再次,然后sudo systemctl start gunicorn.socket并且问题不再存在,并且在检查状态(命令sudo systemctl status gunicorn.socket )后,它最终返回它处于活动状态(正在侦听)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM