def celerybeat(args): if args.command == "start": celerybeat_run(args) elif args.command == "stop": utils.terminate(CELERYBEAT_PIDFILE) elif args.command == "clean": utils.remove_file(CELERYBEAT_PIDFILE) else: raise ValueError("unknown command %s" % args.command)
def supervisord(args): if args.command == "start": supervisord_run(args) elif args.command == "stop": utils.terminate(SUPERVISORD_PIDFILE) elif args.command == "clean": utils.remove_file(SUPERVISORD_PIDFILE) elif args.command == "reload": utils.terminate(SUPERVISORD_PIDFILE, signal.SIGHUP) else: raise ValueError("unknown command %s" % args.command)
def test_terminate(): from metrique.utils import terminate, sys_call, get_pid, clear_stale_pids import signal pid_file = os.path.join(cache_dir, 'test.pid') sys_call('sleep 30', fork=True, pid_file=pid_file, shell=False) sleep(1) pid = get_pid(pid_file) running = clear_stale_pids(pid) assert running terminate(pid, sig=signal.SIGTERM) sleep(1) running = clear_stale_pids(pid) assert not running # since we didn't tell it where to find the pid_file # it won't be cleaned up assert exists(pid_file) # this time we point to a pid_file and it gets cleaned up terminate(pid_file, sig=signal.SIGTERM) assert not exists(pid_file) # invalid pids are ignored assert terminate(-1) is None
def postgresql_terminate(sig=None, frame=None): utils.terminate(POSTGRESQL_PIDFILE)
def nginx_terminate(sig=None, frame=None): utils.terminate(NGINX_PIDFILE)
def supervisord_terminate(sig=None, frame=None): utils.terminate(SUPERVISORD_PIDFILE)
def celerybeat_terminate(sig=None, frame=None): utils.terminate(CELERYBEAT_PIDFILE)
def celeryd_terminate(sig=None, frame=None): utils.terminate(CELERYD_PIDFILE)