benoitc / gunicorn

gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.
http://www.gunicorn.org
Other
9.86k stars 1.75k forks source link

Gunicorn ignores signals #3168

Open VladimirVisnovsky opened 8 months ago

VladimirVisnovsky commented 8 months ago

When running gunicorn with --preload flag, the running master worker ignores signals (TTIN, TTOUT, HUP, etc).

gunicorn -b 0.0.0.0:5000 --worker-class eventlet -w 3 --reload server.wsgi:app --graceful-timeout 10 --preload

For example sending TTIN signal kill -TTIN $master_pid does nothing as well as CTRL+C does not interrupt the server, only kills the workers. Is there a reason these commands do not work with --preload flag? Without the flag gunicorn functionality works (signals, ctrl+c) without any problem. Maybe there is a problem with Flask application and not in Gunicorn?

The whole idea behind usage of --preload flag in my case is the scheduler that I use in Flask application. I need to run some tasks in background but if I spawn more than one worker, the code gets forked and executed multiple times across each worker. In my mind when using --preload flag, the scheduler gets initialized and AFTER that workers get forked. With --preload flag scheduler works as expected with multiple workers but I am stuck with original problem (ignoring signals, etc.)

benoitc commented 3 months ago

how does look the app?