Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use supervisor fo start/stop uWSGI application?

I use a supervisor to run uWSGI application. Why uWSGI application does not always stop after stop supervisor? supervisor config:

[program:test]
autostart = true
user=root
command=uwsgi --master --workers  5 --disable-logging --socket 127.0.0.1:8888
--module web --callable app
priority=1
redirect_stderr=true
stdout_logfile = /data/log
like image 393
Bdfy Avatar asked Oct 22 '13 06:10

Bdfy


4 Answers

By default supervisor send SIGTERM on stop. SIGTERM in uWSGI means 'brutal reload'.

You have to change it to QUIT or INT:

stopsignal=QUIT

should be enough

Another approach (discouraged) is adding --die-on-term to uWSGI command line to change its default behaviour

like image 53
roberto Avatar answered Oct 22 '22 14:10

roberto


  1. project supervisor config file

    add stopsignal=INT

  2. project uwsgi config file

    remove daemonize=xxx.log to disable daemon mode

like image 37
Color Avatar answered Oct 22 '22 13:10

Color


If you use "processes = #" into your uwsgi configuration, you also must use "master = true". If not, supervisor only will kill one of workers.

Then:

/etc/supervisor/conf.d/app.conf

stopsignal = QUIT

/etc/uwsgi/app.ini

processes = 4
master = true
like image 4
estevo Avatar answered Oct 22 '22 15:10

estevo


If you are running your UWSGI with master and workers you need to add in your /etc/supervisor/conf.d/app.conf file

stopasgroup=false
killasgroup=false

or else no matter what stopping uwsgi will spawn more master and so is workers.

like image 1
Kunal Mawar Avatar answered Oct 22 '22 14:10

Kunal Mawar