5

I'm new to gunicorn and trying to deploy a django website on an ubuntu. I have used:

pip3 install gunicorn
sudo apt-get install gunicorn

but when I want to fill this file:

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

and I fill it with:

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

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          myproject.wsgi:application

[Install]
WantedBy=multi-user.target

but there is no gunicorn file in /bin what is the missing part?

by using this command:

sudo journalctl -u gunicorn.socket
sudo systemctl status gunicorn

gunicorn.service: Failed at step EXEC spawning /home/tw/tw_git2/tw_git2/ninipayenv/bin/gunicorn: No such file or directory

Vala Khosravi
  • 2,352
  • 3
  • 22
  • 49
MHB
  • 625
  • 2
  • 10
  • 20
  • Have you activate your virtualenv before run `pip install gunicorn`? – Toan Quoc Ho Oct 24 '19 at 16:21
  • yes @ToanQuocHo – MHB Oct 24 '19 at 16:24
  • 1
    `apt-get` is not going to install anything in a venv. `pip3` could also be a system version. Make sure the venv is active and use just `pip` or `python -m pip`. – Klaus D. Oct 24 '19 at 16:38
  • 1
    try `which pip3` command and see if the directory is your venv's directory or system. – Sarosh Khatana Oct 24 '19 at 16:43
  • 2
    I think to make sure everything setup properly, you could activate your venv, run `which pip`, it supposed to be: `/home/tw/tw_git2/tw_git2/ninipayenv/bin/pip`. To install `gunicorn`, you could also use `/home/tw/tw_git2/tw_git2/ninipayenv/bin/pip install gunicorn` – Toan Quoc Ho Oct 24 '19 at 16:43
  • there is no pip3 in this directory. should I install one? @ToanQuocHo – MHB Oct 30 '19 at 07:59
  • how can I install pip in the virtual environment? which pip3 shows system version pip3 and there is no pip in /bin folder @KlausD. – MHB Oct 30 '19 at 08:07
  • What is the output of `pip --version`, `pip3 --version` and `python -m pip --version`? – Klaus D. Oct 30 '19 at 08:54
  • I have fixed it with reinstalling venv, now I have gunicorn in /bin. but it return new error in status gunicorn. ````gunicorn.socket: Failed with result 'service-start-limit-hit'.```` how can I fix this one? @KlausD. – MHB Oct 30 '19 at 09:12
  • I think you can follow this to give some more details about the problem: https://stackoverflow.com/questions/55093622/gunicorn-socket-failed-with-result-service-start-limit-hit – Toan Quoc Ho Oct 30 '19 at 09:55
  • Please open a new question for the new problem. – Klaus D. Oct 30 '19 at 10:31

1 Answers1

4

it can be fixed with removing the previous venv and creating a new one to be sure that pip3 that is been used is inside the venv.

MHB
  • 625
  • 2
  • 10
  • 20