Gunicorn: Failed At step EXEC spawning No such file or directory
Asked Answered
I

3

6

I am trying to get my gunicorn setup. Following is my config file for the systemmd config file:

# Unit section is used to specify metadata and dependencies
[Unit]
Description=DEMO

# only start once the network target has been reached
After=network.target



# Service section specify the user and group that we want the process to run under
[Service]
# www-data group assigned to facilitate easy communication with nginx
Group=www-data

# path to working directory
WorkingDirectory=/srv/demo/git

# path to virtual environment
Environment="PATH=/srv/demo/git/venv/bin"

ExecStart=/srv/demo/git/venv/bin/gunicorn --workers=5 --bind unix:git.sock --log-level=debug wsgi:app --timeout 3600
#--workers=5 --threads=2 --worker-class=gthread 



[Install]
WantedBy=multi-user.target
~                                                                                                       
~                                                                                                       
~    

                                                                                               

And my virtual environment folder does contain gunicorn:

enter image description here

But I am still unable to run this, the systemmd file says that it was unable to find gunicorn. No such file or directory:

enter image description here

i have uninstall gunicorn from outside my virtual env. But when i do a which gunicorn it shows me the path to be /usr/bin/gunicorn. When i put this path, it dosnt throw the same error but simply says that the apt_pkg and gunicorn module wasnt found but not a directory error. Is this a path issue? If so how can i fix it?

Impi answered 29/7, 2020 at 17:50 Comment(0)
G
9

I hope following steps will be helpful to solve this problem....

Step 1: cd ~/myprojectdir

Step 2: source myprojectenv/bin/activate

Step 3: which gunicorn

Step 4: Paste that into the path section of the ‘ExecStart’ value exchange ‘/etc/systemd/system/gunicorn.service’ by which guicorn '..../path"

Step 5: sudo systemctl daemon-reload

Step 6: sudo systemctl restart gunicorn

Step 7: sudo systemctl status gunicorn

Geanine answered 2/5, 2021 at 9:52 Comment(2)
I had a similar problem when I typed which gunicorn. It didn't show anything. Ended up removing the whole venv and reinstalled it plus the whole requirements.txt. That fixed the problem.Larva
worked for me november 20, 2022Arnulfo
L
0

There are several issues that could raise this but if you have settled everything perfectly then you can try these quick fixes,

  • Make sure gunicorn is installed (pip install gunicorn)
  • confirm that your applications is listening on gunicorn -w 4 -b 0.0.0.0:8000 your_project_name.wsgi:application
  • restart the service and socket again

(sudo systemctl daemon-reload

sudo systemctl restart gunicorn)
Lanark answered 8/4 at 12:29 Comment(0)
M
0

I moved env folder from another path and I got the error. This worked for me:

  1. Delete env folder.
  2. Make a new virtual environment.
  3. Activate virtual environment.
  4. Install requirements.txt packages.
Madgemadhouse answered 29/5 at 11:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.