Skip to content

Conversation

@jimklimov
Copy link
Member

Closes: #1590

While the systemd notifications are first/primary cause of this change, I tried to implement it in a somewhat abstract manner to allow easy extension to other service management frameworks. No strong opinion yet if this should supplant existing (currently nearby) upslogx() or upsdebugx() messages about the lifecycle milestones.

While the watchdog notification support was added, it is currently not configured by the service unit templates (something to do more exploration about to provide decent timeouts, even for busy systems). One idea for the future was to use WATCHDOG_USEC=<NUM> (and EXTEND_TIMEOUT_USEC=<NUM>) messages for drivers (daemons) to actually tell systemd that they want to be watchdogged, e.g. based on optional maxstartdelay setting parsed from ups.conf. For example, full SNMP walks can take a while, tens of seconds or more, and wall-clock times depend on stress and performance of both the monitoring system and UPS interface hardware.

Other NUT units, such as NDE script's service (and related path), are not covered by this change at this time.

Loosely related to #1771 (might conflict a bit). Not sure if this general daemon lifecycle notification support should also get peppered into drivers as thoroughly (e.g. track reconnection attempts as a "reloading" state).

CC @bigon

@jimklimov jimklimov added systemd service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Linux Some issues are specific to Linux as a platform labels Jan 6, 2023
@jimklimov jimklimov added this to the 2.8.1 milestone Jan 6, 2023
@jimklimov
Copy link
Member Author

jimklimov commented Jan 7, 2023

Nice, status messages work - as well as MAINPID setting for systemd to monitor the intended upsd/upsmon/driver process after all the forking involved in starting one:

* nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/lib/systemd/system/nut-server.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Sat 2023-01-07 18:43:17 CET; 19min ago
    Process: 4102332 ExecStart=/usr/local/ups/sbin/upsd -FF (code=exited, status=0/SUCCESS)
   Main PID: 4102332 (code=exited, status=0/SUCCESS)
     Status: "Signal 15: exiting"
        CPU: 4ms

A call to systemctl start nut-driver@eco650 only exits after driver initialization and just before entering the infinite processing loop (where it notifies the READY state to systemd).

…rvice.in: provide an Alias for convenience (upsd, upsmon)
@jimklimov
Copy link
Member Author

Fixed watchdog integration per comments from @poettering and rebased over recent master branch. Hopefully this burst of activity is done :)

@jimklimov jimklimov merged commit 0b487c0 into networkupstools:master Jan 8, 2023
@jimklimov jimklimov deleted the issue-1590 branch January 8, 2023 02:46
jimklimov added a commit to jimklimov/nut that referenced this pull request Aug 4, 2023
… of got_monoclock in upsnotify() [networkupstools#1777 follow-up]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this pull request Aug 4, 2023
…etworkupstools#1777 follow-up]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this pull request Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Linux Some issues are specific to Linux as a platform service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug systemd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On systemd aware OSes, optionally integrate with sd_notify()

1 participant