over 8 years ago
I wrote two simple scripts for starting and stopping a gunicorn server that hosts a Django project.
Create a run.sh:
#!/bin/bash
source `which virtualenvwrapper.sh` #assuming you use virtualenv
workon your_env_name # if you do not use virtualenv, remove this line the line above
gunicorn -c gunicorn.conf.py your_project_name.wsgi --daemon
Create a stop.sh:
#!/bin/bash
kill -9 `ps aux |grep gunicorn |grep your_app_name | awk '{ print $2 }'` # will kill all of the workers
Once these scripts are created, don't forget to set the permission:
chmod 755 run.sh
chmod 755 stop.sh
To run them:
./run.sh
./stop.sh