def install_HUP_not_supported_handler(worker): def warn_on_HUP_handler(signum, frame): worker.logger.error("SIGHUP not supported: " "Restarting with HUP is unstable on this platform!") platform.install_signal_handler("SIGHUP", warn_on_HUP_handler)
def install_HUP_not_supported_handler(worker): def warn_on_HUP_handler(signum, frame): worker.logger.error( "SIGHUP not supported: " "Restarting with HUP is unstable on this platform!") platform.install_signal_handler("SIGHUP", warn_on_HUP_handler)
def install_worker_restart_handler(worker): def restart_worker_sig_handler(signum, frame): """Signal handler restarting the current python program.""" worker.logger.warn("Restarting celeryd (%s)" % (" ".join(sys.argv))) worker.stop() os.execv(sys.executable, [sys.executable] + sys.argv) platform.install_signal_handler("SIGHUP", restart_worker_sig_handler)
def install_worker_term_handler(worker): def _stop(signum, frame): process_name = multiprocessing.current_process().name if process_name == "MainProcess": worker.logger.warn("celeryd: Warm shutdown (%s)" % (process_name)) worker.stop() raise SystemExit() platform.install_signal_handler("SIGTERM", _stop)
def install_sync_handler(self, beat): """Install a ``SIGTERM`` + ``SIGINT`` handler that saves the celerybeat schedule.""" def _sync(signum, frame): beat.sync() raise SystemExit() platform.install_signal_handler("SIGTERM", _sync) platform.install_signal_handler("SIGINT", _sync)
def install_worker_int_again_handler(worker): def _stop(signum, frame): process_name = multiprocessing.current_process().name if process_name == "MainProcess": worker.logger.warn("celeryd: Cold shutdown (%s)" % (process_name)) worker.terminate() raise SystemExit() platform.install_signal_handler("SIGINT", _stop)
def install_worker_term_handler(worker): def _stop(signum, frame): if current_process().name == 'MainProcess': worker.logger.warn("Stopping celeryd (%s)" % \ (current_process().name)) worker.stop() raise SystemExit() platform.install_signal_handler("SIGTERM", _stop)
def install_worker_int_handler(worker): def _stop(signum, frame): if multiprocessing.current_process().name == 'MainProcess': worker.logger.warn("celeryd: Cold shutdown (%s)" % \ (current_process().name)) worker.terminate() raise SystemExit() platform.install_signal_handler("SIGINT", _stop)
def install_worker_int_handler(worker): def _stop(signum, frame): process_name = multiprocessing.current_process().name if process_name == "MainProcess": worker.logger.warn("celeryd: Hitting Ctrl+C again will terminate " "all running tasks!") install_worker_int_again_handler(worker) worker.logger.warn("celeryd: Warm shutdown (%s)" % (process_name)) worker.stop() raise SystemExit() platform.install_signal_handler("SIGINT", _stop)
def install_worker_int_handler(worker): def _stop(signum, frame): process_name = multiprocessing.current_process().name if process_name == "MainProcess": worker.logger.warn( "celeryd: Hitting Ctrl+C again will terminate " "all running tasks!") install_worker_int_again_handler(worker) worker.logger.warn("celeryd: Warm shutdown (%s)" % ( process_name)) worker.stop() raise SystemExit() platform.install_signal_handler("SIGINT", _stop)
def install_worker_restart_handler(worker): def restart_worker_sig_handler(signum, frame): """Signal handler restarting the current python program.""" worker.logger.info("Restarting celeryd (%s)" % ( " ".join(sys.argv))) if worker.is_detached: pid = os.fork() if pid: worker.stop() sys.exit(0) else: worker.stop() os.execv(sys.executable, [sys.executable] + sys.argv) platform.install_signal_handler("SIGHUP", restart_worker_sig_handler)
def install_worker_term_handler(worker): def _stop(signum, frame): raise SystemExit() platform.install_signal_handler("SIGTERM", _stop)