I'm starting gunicorn with the Django command python manage.py run_gunicorn
. How can I stop gunicorn properly?
Note: I have a semi-automated server deployment with fabric. Thus using something like ps aux | grep gunicorn
to kill the process manually by pid is not an option.
You should receive the HTML output from your application in the terminal. This confirms that Gunicorn was started and able to serve your Django application. You can verify that the Gunicorn service is running by checking the status again: sudo systemctl status gunicorn.
If you are running gunicorn on a port rather than a socket, you can find the process id (pid) of gunicorn using fuser command. Then force gunicorn to reload the code by sending a HUP signal.
your pid file location is /run/gunicorn/gunicorn.
As a server runner, Gunicorn can serve your application using the commands from your framework, such as pserve or gearbox . To use Gunicorn with these commands, specify it as a server in your configuration file: [server:main] use = egg:gunicorn#main host = 127.0.0.1 port = 8080 workers = 3.
To see the processes is ps ax|grep gunicorn
and to stop gunicorn_django is pkill gunicorn
.
One option would be to use Supervisor
to manage Gunicorn.
Then again i don't see why you can't kill the process via Fabric
. Assuming you let Gunicorn write a pid file you could easily read that file in a Fabric
command.
Something like this should work:
run("kill `cat /path/to/your/file/gunicorn.pid`")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With