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.)
EDIT: the problem seems to be with using monkey_patch of eventlet with --preload (github) I am using in my application. Steps to reproduce the issue:
flask_app.py
1 import eventlet
2 eventlet.monkey_patch()
3 from flask import Flask
4
5 app = Flask(__name__)
6
7
8 @app.route("/")
9 def hello():
10 return "<h1 style='color:blue'>Hello There!</h1>"
11
12 if __name__ == "__main__":
13 pass
wsgi.py
1 from flask_app import app
2
3 if __name__ == "__main__":
4 app.run()
command to start gunicorn server:
gunicorn -b 0.0.0.0:5000 --worker-class eventlet -w 3 wsgi:app --preload