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
Enhance ways that upsd/upsmon can send signals to their running siblings #1300
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…cess runs, no need to send that twice
…ell more about the error
…nd sendsignalpid() reusable methods
…se it in systemd/nut-server.service [for networkupstools#1299]
…dsignal(), like in upsd [for networkupstools#1299, networkupstools#123]
jimklimov
added
systemd
service/daemon start/stop
General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug
refactor/fightwarn
PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
labels
Feb 16, 2022
…similar to that in upsd.c
…out run-time config reload with DEBUG_MIN setting in sight
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
refactor/fightwarn
PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
service/daemon start/stop
General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug
systemd
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to address concerns from issues like #123 and #1299 and optionally allow service daemon lifecycle without a PID file, including sending of signals for
reload
and other operations.It adds two ways of addressing the original problems:
-F
argument twice (e.g.upsd -FF
), so that service integrations, init-scripts, etc. that would switch to using a non-forking daemon can still manage it with a PID file-P pidnum
argument on command line ofupsd
andupsmon
to directly tell it the PID number of the process to signal, instead of reading the value from a PID file. This should play well with systemd units that can pass a$MAINPID
variable and that is not ambiguous (upsd
).As part of the solution, it refactors
sendsignalfn()
into reusable pieces, addingsendsignalpid()
andparsepid()
methods.It also addresses a cosmetic problem (reports of missing PID file during daemon start) where such file is probed to see if a previous instance of the daemon is running and so might conflict, and a missing file may be a problem or just means there is no competition. Logging should now be clearer about that, e.g.:
Building on
debug_min
support from #683 this PR allows to change (comment/uncomment) thedebug_min NUMBER
setting inupsd.conf
orupsmon.conf
andsystemctl reload nut-server
orsystemctl reload nut-monitor
respectively, to tune debugging verbosity in the running service daemon (it is recommended to comment it away or set the minimum to explicit zero when done, to avoid huge journals and I/O system abuse). Note that for this run-time tuning, thedebug_min
value present in reloaded configuration files is applied instantly and overrides any previously set value, from file or CLI options, regardless of older logging level being higher or lower than the newly found number.Note that this PR does not fully address questions from #123 about PID file (and "main PID" seen by systemd, for that matter) of
upsmon
which by default forks anyway into a privileged part that can shut down the system, and unprivileged child that is networked for monitoring etc. (the PID file remains that of the latter). It also does not address the location of this PID file (by default /var/run/upsmon.pid) questioned in #1297 since for the root-half of the daemon the concern is a moot point.