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 systemd/sd_notify support to CLI #1027

Closed
bensheldon opened this issue Aug 3, 2023 · 0 comments · Fixed by #1029
Closed

Add systemd/sd_notify support to CLI #1027

bensheldon opened this issue Aug 3, 2023 · 0 comments · Fixed by #1029

Comments

@bensheldon
Copy link
Owner

Since #988, it would be nice to have better systemd support (ideally GoodJob is run in a containerized environment; I think systemd is the best alternative to that).

Two examples of this:

I'm partial to Sidekiq's decision to simply vendor the SdNotify.

@bensheldon bensheldon changed the title Add SystemD/sd_notify support to CLI Add systemd/sd_notify support to CLI Aug 3, 2023
Mr0grog added a commit to Mr0grog/good_job that referenced this issue Aug 4, 2023
This adds a somewhat naive `SystemdService` class that will send appropriate notifications to systemd or do nothing if it doesn't detect that the process is being run by systemd. It pretty much just notifies that the process is ready, is stopping, and actively notifies the watchdog while it's running. It doesn't reach into the actual job system to check that things are OK, or hook into ActiveSupport notifications to tell systemd about other events (like restarting/reloading).

Fixes bensheldon#1027.
bensheldon pushed a commit that referenced this issue Aug 6, 2023
* First pass on systemd integration

This adds a somewhat naive `SystemdService` class that will send appropriate notifications to systemd or do nothing if it doesn't detect that the process is being run by systemd. It pretty much just notifies that the process is ready, is stopping, and actively notifies the watchdog while it's running. It doesn't reach into the actual job system to check that things are OK, or hook into ActiveSupport notifications to tell systemd about other events (like restarting/reloading).

Fixes #1027.

* Log using notifications

* Add some docs

* Handle graceful shutdown notifications better

* Update Sorbet typing information

* Systemd errors should probably always log

* Add tests

* Add example systemd configuration file

* Make Sorbet happy

Stubbed constants are very not cool as far as Sorbet is concerned, so the way I wrote these tests before broke the linter. OTOH, trying to figure out how to make this acceptable did get some slightly nicer test setup.

* Skip socket tests on JRuby

* Move vendored sd_notify into lib/

* Add note about test skipping

It's good to know why these are skipped so we can stop skipping them in the future if the JRuby issue is fixed (or someone figures out a workaround).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
1 participant