I am following this How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04 guide.
I have created the following 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. 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. Ubunto 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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.