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

[feature request] sending signals to services #134

Closed
CMB opened this issue Dec 14, 2022 · 5 comments
Closed

[feature request] sending signals to services #134

CMB opened this issue Dec 14, 2022 · 5 comments
Labels
A-Importance: Normal C-dinit Things about the main parts of dinit C-dinit-service Things about dinit-service C-dinitctl Things about dinitctl Feature Request Request a feature to be added to dinit

Comments

@CMB
Copy link

CMB commented Dec 14, 2022

It would be nice if I could use dinitctl to signal a service.
Like with runit, I can say sv hup lighttpd to tell lighttpd to reload its config.

@mobin-2008 mobin-2008 added C-dinitctl Things about dinitctl C-dinit Things about the main parts of dinit C-dinit-service Things about dinit-service Feature Request Request a feature to be added to dinit labels Dec 16, 2022
@mobin-2008
Copy link
Collaborator

Hi. I thinked about it. Most UNIX-like systems (such as Linux based and BSDs and even Solaris) have kill and pkill. pkill is very easy to use:

# for example tell nginx to reload its config
pkill -HUP nginx

I don't see a special case to need a special command to send a signal to services because kill and pkill are exist.

@CMB
Copy link
Author

CMB commented Dec 17, 2022

Yes kill and pkill will do it, but they may cause collateral damage.
E.G., multiple nginx services running on one system.
The kill and pkill commands operate at the wrong granularity.

Better than pkill would be to ask dinit for the pid, like so:

kill -HUP "$( dinitctl list |grep ' postgres ' |sed -E 's;^.*pid: ([0-9]+).*;\1;')"

Signaling processes is also racy when you aren't the parent.
There's a race window between the time you obtain the PID and the time you signal the process,
during which the PID might have been recycled. Granted, the window is pretty tiny, but the kill command is still an act of faith.
With a supervised service, type=process in dinit, dinit is the parent, and it can signal the appropriate child in a race-free way.

@davmac314
Copy link
Owner

Note that the usual policy is not to accept feature requests without a patch (see the README) but in this case, yes, it's something that is planned.

@james-knippes
Copy link
Contributor

I've implemented signal support in #176 in hopes it may be useful. I would appreciate feedback. I assume the implementation covers your request @CMB ?

@mobin-2008
Copy link
Collaborator

I forgot to close this issue. This feature has been added in #176 and will be available in 0.17 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Importance: Normal C-dinit Things about the main parts of dinit C-dinit-service Things about dinit-service C-dinitctl Things about dinitctl Feature Request Request a feature to be added to dinit
Projects
None yet
Development

No branches or pull requests

4 participants