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

Implement start and stop lifecycle hooks for the supervisor and workers #317

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

rosa
Copy link
Member

@rosa rosa commented Sep 2, 2024

This is a simple first implementation for those. With this, you can register blocks of code to be called after the supervisor finishes booting but right before it forks workers and dispatchers (start) and before it starts to shut down, gracefully or immediately (stop).

It works like this:

SolidQueue.on_start { start_metrics_server }
SolidQueue.on_stop { stop_metrics_server }

You can do the same for workers, with registered blocks being called before the worker starts polling (worker_start) and right before it shuts down its thread pool (worker_stop):

SolidQueue.on_worker_start { AnotherExtension.stopping = false }
SolidQueue.on_worker_stop { AnotherExtension.stopping = true }

Any errors raised by these blocks will be passed over to on_thread_error and won't be re-raised.

As these would be needed for job-iteration to know when the worker is
going to stop.
@rosa rosa changed the title Implement start and stop lifecycle hooks for the supervisor Implement start and stop lifecycle hooks for the supervisor and workers Sep 4, 2024
@rosa rosa merged commit 835ec4d into main Sep 4, 2024
8 checks passed
@rosa rosa deleted the start-stop-callbacks branch September 4, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant