Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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)
Ejemplo n.º 15
0
def install_worker_term_handler(worker):

    def _stop(signum, frame):
        raise SystemExit()

    platform.install_signal_handler("SIGTERM", _stop)