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

Cleanly stop a service group if a service exits #332

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

robbevp
Copy link
Contributor

@robbevp robbevp commented Dec 14, 2024

This fixes a small issue with service groups (that I noticed a few months ago and forgot about myself).

If a service in a group encounters an EXIT the whole group stops, but the pidfile isn't cleaned up. To start the service again I would then have to call service:stop and service:start. By trapping EXIT, we also cleanly stop the group and will clean up the pidfile.

I also added a check to see if the process is still running before killing is. Otherwise we'd get a print saying that the process doesn't exist:

09:16:06 system | ruby.1 started (pid=61570)
09:16:06 ruby.1 | main fn
09:16:06 system | ruby.1 stopped (rc=0)
/nix/store/kslx6csgb2bl13sp438vsx5kiq7s788c-example-services-start: line 11: kill: (61565) - No such process

A minimal reproduction of this issue can be found here: https://git.robbevp.be/robbevp/devshell-ruby-reproduction
Updating the devshell input to this branch fixes the issue.

@robbevp robbevp force-pushed the fix/stop-service-exit branch from ff72216 to 81e38d4 Compare December 14, 2024 08:26
@zimbatm zimbatm merged commit 4d062a4 into numtide:main Dec 31, 2024
6 of 10 checks passed
# 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.

3 participants