Debian – Supervisor cannot correctly stop uwsgi

debianpythonsupervisorduwsgi

Supervisor can start uwsgi but after stopping uwsgi, when i try to start it again I get this error:

2014-03-16 08:38:34,249 DEBG 'app' stderr output:                                                                                      
thunder lock: disabled (you can enable it with --thunder-lock)                                                                         

2014-03-16 08:38:34,249 DEBG 'app' stderr output:                                                                                      
probably another instance of uWSGI is running on the same address (127.0.0.1:8001).                                                    

2014-03-16 08:38:34,249 DEBG 'app' stderr output:                                                                                      
bind(): Address already in use [core/socket.c line 759]                                                                                

2014-03-16 08:38:34,250 DEBG fd 11 closed, stopped monitoring <POutputDispatcher at 33121488 for <Subprocess at 32641104 with name app 
in state STARTING> (stdout)>                                                                                                           
2014-03-16 08:38:34,250 DEBG fd 15 closed, stopped monitoring <POutputDispatcher at 33122208 for <Subprocess at 32641104 with name app 
in state STARTING> (stderr)>                                                                                                           
2014-03-16 08:38:34,250 INFO exited: app (exit status 1; not expected)                                                                 
2014-03-16 08:38:34,250 DEBG received SIGCLD indicating a child quit                                                                   
2014-03-16 08:38:35,251 INFO gave up: app entered FATAL state, too many start retries too quickly 

It seems it didn't correctly stop uwsgi as when it tries to restart it there is a problem. My config for uwsgi for supervisor is as follows:

[program:uwsgi]
command=/usr/local/bin/uwsgi --ini /etc/conf/uwsgi_$APP.ini
user=uwsgi
autostart=true
autorestart=true
stderr_logfile=uwsgi_err.log
stdout_logfile=uwsgi_out.log
stopsignal=INT

I have also tried this with stopsignal=quit. Where have I gone wrong?

Best Answer

You need to give uwsgi the pidfile of the process you're trying to stop: http://uwsgi-docs.readthedocs.org/en/latest/Options.html#stop