Skip to content
New issue

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

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

Already on GitHub? # 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.

rosa added 2 commits September 3, 2024 20:12
As these would be needed for job-iteration to know when the worker is
going to stop.
@rosa rosa force-pushed the start-stop-callbacks branch from f961df0 to 18f89e5 Compare September 3, 2024 19:42
@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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant