python - Registering SIGINT/SIGQUIT signals in a Django application served in Docker -


i've got django application queue system (that builds releases various developers) needs completed. however, towards end of day, need shut down running builds should not terminated. achieve this, thought can catch termination signals (like sigint/sigquit/sigterm) application can wait releases complete , shut system down then.

i have following signal registering system:

import time, sys, signal  def signal_handler(signum, frame):     print('waiting releases complete')     time.sleep(5)     print('terminating gracefully...')     sys.exit(0)  sig in [signal.sigterm, signal.sigint, signal.sigquit]:     signal.signal(sig, signal_handler) 

when run django's development server command line code snippet, registers signal , trigger handler function. problem application runs on docker nginx , uwsgi in place. when run container, registers signal when stop docker container, sigint/sigquit signal caught uwsgi, not python , signal handler not triggered.

i'm relatively new docker , uwsgi, couldn't figure out way send signal directly python. should python catch signal, not uwsgi?

any appreciated.

edit: here's entrypoint script.

entrypoint.sh

#!/bin/sh  # start uwsgi using configuration file exec uwsgi --ini ./docker/django/uwsgi.ini 

uwsgi.ini

... module = app.wsgi socket = path/to/unix/socket.sock chmod-socket = 666 ... 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

javascript - Rivets.js rv-show not working with rv-each -