Can somebody explain how gunicorn handles SIGTERM or SIGINT signals

Viewed 708

I run application via gunicorn with single worker. So, I have main process (let say, wth id=12). Also I can create another process from main using multiprocessing (id = 20, whatever). Also I want to provide possibility to interrupt child process (with id=20). To achieve this, from main process call os.kill(20, signal.SIGTERM). Also, custom handler for SIGTERM signal provided.

The problem is, that if application catches the signal, process (id=20) stopped as I expected, but also main process stopped after, too. And worker restarts.

The docs (https://docs.gunicorn.org/en/latest/signals.html#master-process) pretty poor or maybe I something missed.

I've playing around for a while and realized that I can stop child process via SIGUSR1 or SIGUSR2 without worker restarting (of course, if my custom method provided for this signals).

But I'm not sure, is it correct way to stop process. Or maybe I can do same with SIGTERM, somehow.

Thanks.

0 Answers
Related