From 4bee4b53379f67acb083ea64027a3a09d478ca5c Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Wed, 18 Oct 2023 14:42:31 +0200 Subject: [PATCH] Add restart option pulpcore-worker [noissue] --- CHANGES/+pulpcore-worker-restart.feature | 1 + pulpcore/tasking/entrypoint.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 CHANGES/+pulpcore-worker-restart.feature diff --git a/CHANGES/+pulpcore-worker-restart.feature b/CHANGES/+pulpcore-worker-restart.feature new file mode 100644 index 00000000000..4ec3f437537 --- /dev/null +++ b/CHANGES/+pulpcore-worker-restart.feature @@ -0,0 +1 @@ +Added a ``--restart`` option to pulpcore worker. This requires "hupper" to be installed. diff --git a/pulpcore/tasking/entrypoint.py b/pulpcore/tasking/entrypoint.py index 95626255f4a..60d8fd1f999 100644 --- a/pulpcore/tasking/entrypoint.py +++ b/pulpcore/tasking/entrypoint.py @@ -18,10 +18,18 @@ @click.option( "--burst/--no-burst", help="Run in burst mode; terminate when no more tasks are available." ) +@click.option( + "--reload/--no-reload", help="Reload worker on code changes. [requires hupper to be installed." +) @click.command() -def worker(pid, burst): +def worker(pid, burst, reload): """A Pulp worker.""" + if reload: + import hupper + + hupper.start_reloader(__name__ + ".worker") + if pid: with open(os.path.expanduser(pid), "w") as fp: fp.write(str(os.getpid()))