Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restart option pulpcore-worker #4685

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/+pulpcore-worker-restart.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a ``--restart`` option to pulpcore worker. This requires "hupper" to be installed.
Copy link
Member

@ipanova ipanova Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this new way of adding a record to the changelog? there is no issue filed but you have pulpcore-worker-restart.features?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The + allows you to create an "orphan" changelog entry (or an entry without an issue).

twisted/towncrier#428

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 changes: 13 additions & 1 deletion pulpcore/tasking/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@
@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:
try:
import hupper
except ImportError:
click.echo("Could not load hupper. This is needed to use --reload.", err=True)
exit(1)

hupper.start_reloader(__name__ + ".worker")

if pid:
with open(os.path.expanduser(pid), "w") as fp:
fp.write(str(os.getpid()))
Expand Down