I am sending SIGTERM
signal to my server via start-stop-daemon
. As expected the server shuts down when signal is received. Now I want to halt my server for 10 sec after receiving SIGTERM
and then shut it down. To achieve this I wrote
def sigterm_handler(signum):
time.sleep(10)
sys.exit(0)
Class server(object):
.
.
def __call__()
signal.signal(signal.SIGTERM, sigterm_handler)
#some code
.
.
Now the server never waits for 10 secs after receiving signal. As soon as the signal is send, it shuts down (checked in loggers).
Also the following message halts for 10 secs on my terminal.
* Stopping Server:
I think my code is not able to tell python that the signal is being handled and so, the default handler is also being called along with my handler. Any idea what needs to be done?