As a preface, I've got a python script running flask being served by gunicorn running as a service. One command this service takes is a long running function that runs anywhere from 5-10 minutes. When the gunicorn service receives a SIGTERM it waits 10 minutes, then kills itself, this way the long running process can continue.

The current action on restart is it waits 10 minutes, kills the current process, then starts a new one.

What I'd like to do on restart is send a SIGUSR2 to the current service to start a new one, then send the SIGTERM to end the old one.

I believe an alternative to all this would be to manually send the SIGUSR2 and SIGTERM signals then update the running service's PID to the new one? I'm not totally sure what my best options are here.


Turns out I should have looked a little more closely at builtin options for gunicorn. Simply sending a HUP signal to the process hangs up the master, sends a winch to create new workers then terminates the old workers and reconnects the master.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.