Skip to content

Commit 826c7f5

Browse files
committed
Add restart option pulpcore-worker
[noissue]
1 parent 417a8d1 commit 826c7f5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a ``--restart`` option to pulpcore worker. This requires "hupper" to be installed.

pulpcore/tasking/entrypoint.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@
1818
@click.option(
1919
"--burst/--no-burst", help="Run in burst mode; terminate when no more tasks are available."
2020
)
21+
@click.option(
22+
"--reload/--no-reload", help="Reload worker on code changes. [requires hupper to be installed.]"
23+
)
2124
@click.command()
22-
def worker(pid, burst):
25+
def worker(pid, burst, reload):
2326
"""A Pulp worker."""
2427

28+
if reload:
29+
try:
30+
import hupper
31+
except ImportError:
32+
click.echo("Could not load hupper. This is needed to use --reload.", err=True)
33+
exit(1)
34+
35+
hupper.start_reloader(__name__ + ".worker")
36+
2537
if pid:
2638
with open(os.path.expanduser(pid), "w") as fp:
2739
fp.write(str(os.getpid()))

0 commit comments

Comments
 (0)