Reputation: 577
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:
But I am still unable to run this, the systemmd file says that it was unable to find gunicorn. No such file or directory:
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
Reputation: 571
I moved env folder from another path and I got the error. This worked for me:
Upvotes: 0
Reputation: 131
There are several issues that could raise this but if you have settled everything perfectly then you can try these quick fixes,
pip install gunicorn
)gunicorn -w 4 -b 0.0.0.0:8000 your_project_name.wsgi:application
(sudo systemctl daemon-reload
sudo systemctl restart gunicorn)
Upvotes: 0
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