How to Catch Harakiri in Django

I would like to catch a “hara-kiri signal” in a django application to register some information.

This code makes hara-kiri from uwsgi sources:

if (uwsgi.workers[i].pid > 0) { kill(uwsgi.workers[i].pid, SIGUSR2); // allow SIGUSR2 to be delivered sleep(1); kill(uwsgi.workers[i].pid, SIGKILL); } 

I tried to catch the signal SIGUSR2 (views.py):

 import signal def signalhandler(signum, frame): print "!!! harakiri" import logging logger = logging.getLogger("log") logger.error("harakiri !!!!!!!") signal.signal(signal.SIGUSR2, signalhandler) 

but that will not work. I do not see the logs in my code: - (

+4
source share

Source: https://habr.com/ru/post/1416511/


All Articles