From 75a1236e0bc7be3b345b12ff5f4b1c14b0a0e010 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 15 Jul 2016 10:05:54 -0600 Subject: [PATCH] Stop workers on demand --- teuthology/worker.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/teuthology/worker.py b/teuthology/worker.py index e314e7968..84b9f33c8 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -21,6 +21,7 @@ from .repo_utils import fetch_qa_suite, fetch_teuthology log = logging.getLogger(__name__) start_time = datetime.utcnow() restart_file_path = '/tmp/teuthology-restart-workers' +stop_file_path = '/tmp/teuthology-stop-workers' def sentinel(path): @@ -40,6 +41,11 @@ def restart(): os.execv(sys.executable, args) +def stop(): + log.info('Stopping...') + sys.exit(0) + + def install_except_hook(): """ Install an exception hook that first logs any uncaught exception, then @@ -94,6 +100,8 @@ def main(ctx): if sentinel(restart_file_path): restart() + elif sentinel(stop_file_path): + stop() job = connection.reserve(timeout=60) if job is None: -- 2.47.3