Abhishek Malik
Abhishek Malik

Reputation: 577

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

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?

Upvotes: 6

Views: 15445

Answers (3)

ShayanKM
ShayanKM

Reputation: 571

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.

Upvotes: 0

Asad Ali
Asad Ali

Reputation: 131

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)

Upvotes: 0

Jahirul islam
Jahirul islam

Reputation: 536

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

Upvotes: 9

Related Questions