Implement an INSTCMD driver.exit as alternative to PID files and signals#2393
Implement an INSTCMD driver.exit as alternative to PID files and signals#2393jimklimov merged 10 commits intonetworkupstools:masterfrom
INSTCMD driver.exit as alternative to PID files and signals#2393Conversation
Signed-off-by: Jim Klimov <[email protected]>
Signed-off-by: Jim Klimov <[email protected]>
(note that signals and exit-flags have different numbering, so while
|
|
If the command is sent when a driver is not running, it does not take long: NOTE: Similarly to PR #2384 we do not want "scary noise" when we preemptively try to stop a sibling and can't because none is running - goal achieved, nothing to complain about. |
This comment was marked as resolved.
This comment was marked as resolved.
…mplement "INSTCMD driver.exit" [networkupstools#2392] Signed-off-by: Jim Klimov <[email protected]>
|
✅ Build nut 2.8.2.1648-master completed (commit 8487179896 by @jimklimov) |
…rbosity toggle [networkupstools#1782, networkupstools#2392, networkupstools#2384] Signed-off-by: Jim Klimov <[email protected]>
…we got a signal ourselves (e.g. user pressed Ctrl+C) Signed-off-by: Jim Klimov <[email protected]>
…ush scary noise from attempts to "driver.exit" a sibling [networkupstools#1782, networkupstools#2392, networkupstools#2384] Signed-off-by: Jim Klimov <[email protected]>
…TCMD driver.exit" in some builds [networkupstools#2392] Signed-off-by: Jim Klimov <[email protected]>
|
Screenshots from a build of this PR merged with #2384 for quieter logs (anyhow they will soon be together in master branch):
TODO: "Asking" => "Asked" |
…networkupstools#2392] Signed-off-by: Jim Klimov <[email protected]>
Signed-off-by: Jim Klimov <[email protected]>
…h "INSTCMD driver.exit" so that we can make that verbose again if dialog started but failed to stop the other driver [networkupstools#2384, networkupstools#2392] Signed-off-by: Jim Klimov <[email protected]>
|
Screenshots again, with updated messages:
|
|
Calling commands on the driver is not compromised by the new feature, e.g.: |
When a NUT driver starts, by default it checks the PID file (if present) to kill off its earlier running instance, if any, to have the device connection available and no logical conflicts at run-time.
Problems can arise when the PID file is not available (e.g. not saved due to service unit set-up). Technically we have a fallback capability of checking for the old driver instance via Unix socket made for driver-server communications, and since #1903 and numerous later issues and PRs we can have driver instances (and
upsdrvctl) interact over this channel.This PR adds a new Unix socket protocol command,
driver.exitwhich can be used similar toSIGTERMand so cleanly exit the NUT driver program (with the goal of a new instance being able to start). Note that if the deceased instance was managed by systemd, it would be restarted after a short throttling timeout.At this time of initial posting, this was implemented and tested as a
driver -a upscfg -c exitsort of CLI operation, and tested withusbhid-upsand withupsdrvctlvs. a driver running as a systemd unit.Next step would be to add a similar call to where we check for PID files and ensure "clean-up" before starting the NUT driver for monitoring (as opposed to killpower, instant commands and other side activities).
Closes: #2392