Reputation: 5863
I am using fabric for site deployment which uses gunicorn.
I have following code which is called by deploy()
function.
def restart_gunicorn():
sudo('ps ax|grep gunicorn')
sudo('pkill -HUP -f [g]unicorn.*master')
sudo('gunicorn -b 0.0.0.0:8080 %(path)s/application/wsgi &' % env)
when I run my fab file it shows following:
out: 7694 pts/18 S+ 0:00 grep gunicorn
[127.0.0.1:2222] out:
[127.0.0.1:2222] sudo: pkill -HUP -f [g]unicorn.*master
[127.0.0.1:2222] out: sudo password:
[127.0.0.1:2222] out:
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: pkill -HUP -f [g]unicorn.*master
I think it should kill gunicorn and restart it.. What I am missing here ??
Upvotes: 0
Views: 1230
Reputation: 53774
That is because your gunicorn process isn't named exactly as gunicorn
and you maybe having more than one gunicorn process running (master and workers).
It is usually the master that you want to kill. It's very rarely that you want to kill it out right, more often you just want to reload your code so -HUP is sufficient. So try this:
sudo('pkill -HUP -f [g]unicorn.*master')
Based on your comments, it seems that most of your problems are due to Gunicorn not running on your system at all. There are two options, you can do a test before hand, or you can just use warn_only
with settings(warn_only=True):
sudo('pkill -HUP -f [g]unicorn.*master')
sudo('gunicorn -b 0.0.0.0:8080 %(path)s/application/wsgi &' % env)
Note that your sudo('ps ax|grep gunicorn') line isn't needed here.
Upvotes: 5