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

Introduce sdcommands option and shutdown.default INSTCMD to all drivers #2686

Merged
merged 97 commits into from
Dec 7, 2024

Conversation

jimklimov
Copy link
Member

Closes: #2670

Started from discussion in the issue linked above, about drivers hard-coding some operations as their late-shutdown implementation -- which may not be the best fit for a particular supported device model.

This PR aims to allow one to configure (a generally comma-separated list of) sdcommands option with arbitrary INSTCMD values supported by the device-specific part of driver code (if any). In testing e.g. beeper commands can be used instead of powering off the load.

It also aliases the call to upsdrv_shutdown() as a shutdown.default for good measure (similar to driver.killpower but without a failsafe flag, and not necessarily exiting the driver).

Shutdown implementations of some drivers got reshuffled into newly supported standard instant commands like shutdown.return or shutdown.stayoff - sometimes guessing the name (testing wanted). For others, the method code remains unique (e.g. when return/stayoff is chosen based on OL/OB status).

…rom upsdrv_shutdown() to upscmd("shutdown.stayoff") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…sdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…m upsdrv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…m upsdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…upsdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rom upsdrv_shutdown() to upscmd("shutdown.stayoff") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…() so drivers might implement their own "shutdown.default" at will [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…tinfo() where we register INSTCMD handlers [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…fallback() so drivers might implement their own "shutdown.default" at will [networkupstools#2670]"

This reverts commit 25250b0:
too messy in logs where driver.instcmd() think they are last in stack.

Signed-off-by: Jim Klimov <[email protected]>
…" as upsdrv_shutdown() in main loop too [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov added feature need testing Code looks reasonable, but the feature would better be tested against hardware or OSes service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved labels Nov 19, 2024
@jimklimov jimklimov added this to the 2.8.3 milestone Nov 19, 2024
@AppVeyorBot
Copy link

@jimklimov
Copy link
Member Author

Per #2670 (comment) real-life testing succeeded with usbhid-ups and 3 different APC UPS:

  • SUA750RMI1U (older model);
  • SMT1500RMI1U and SMT1500RMI2U (newer models).

@jimklimov
Copy link
Member Author

jimklimov commented Dec 2, 2024

Also checked with make check-NIT-sandbox-devel &, using upscmd against the dummy driver (tool logs and driver logs landing in same terminal):

:; ./clients/upscmd -u admin -p "$TESTPASS_ADMIN" -w "UPS1@localhost:$NUT_PORT" shutdown.default
Instant command: [email protected] did shutdown.default on UPS1 (tracking ID: 2DDC5036-F665-4D29-BE4C-0374D091D263)
instcmd: unknown command [shutdown.default] [(null)]
shutdown not supported
tracking ID: 2DDC5036-F665-4D29-BE4C-0374D091D263       result: SUCCESS
SUCCESS

Note the drivers do not exit now due to INSTCMD alone (because if (handling_upsdrv_shutdown > 0) set_exit_flag(EF_EXIT_FAILURE);):

:; ./clients/upscmd -u admin -p "$TESTPASS_ADMIN" -l "UPS1@localhost:$NUT_PORT"
Instant commands supported on UPS [UPS1]:

driver.killpower - Description unavailable
driver.reload - Description unavailable
driver.reload-or-error - Description unavailable
driver.reload-or-exit - Description unavailable
load.off - Description unavailable
shutdown.default - Description unavailable

It does however set the flag and exit when we "kill power" using drivername -k (which uses a different INSTCMD driver.killpower that toggles handling_upsdrv_shutdown=1 and calls same upsdrv_shutdown() ultimately):

:; ./drivers/dummy-ups -a UPS1 -DDDDDD -k
   0.000002     [D5:61105] send_to_all: SETINFO driver.state "init.starting"
Network UPS Tools 2.8.2.1303.84-1387-g019529e68 (development iteration after 2.8.2) - Device simulation and repeater driver 0.20
   0.000075     [D5:61105] do_upsconf_args: confupsname=(null), var=maxretry, val=3
   0.000101     [D5:61105] do_upsconf_args: call do_global_args()
   0.000107     [D3:61105] do_global_args: var='maxretry' val='3'
   0.000112     [D5:61105] do_upsconf_args: confupsname=(null), var=driverpath, val=/home/jim/nut/drivers
   0.000118     [D5:61105] do_upsconf_args: call do_global_args()
   0.000121     [D3:61105] do_global_args: var='driverpath' val='/home/jim/nut/drivers'
   0.000124     [D5:61105] do_upsconf_args: confupsname=dummy, var=driver, val=dummy-ups
   0.000128     [D5:61105] do_upsconf_args: confupsname=dummy, var=desc, val=Crash Dummy
   0.000131     [D5:61105] do_upsconf_args: confupsname=dummy, var=port, val=dummy.seq
   0.000151     [D5:61105] do_upsconf_args: confupsname=UPS1, var=driver, val=dummy-ups
   0.000155     [D5:61105] do_upsconf_args: call main_arg()
   0.000177     [D3:61105] main_arg: var='driver' val='dummy-ups'
   0.000198     [D5:61105] do_upsconf_args: not a main_arg()
   0.000218     [D5:61105] do_upsconf_args: this is a 'driver' setting, may we proceed?
   0.000224     [D6:61105] testval_reloadable: var=driver, oldval=dummy-ups, newval=dummy-ups, reloadable=0, reload_flag=0
   0.000226     [D6:61105] testval_reloadable: verdict for (re)loading var=driver value: -1
   0.000247     [D5:61105] do_upsconf_args: 'driver' setting already applied with this value
   0.000255     [D5:61105] do_upsconf_args: confupsname=UPS1, var=desc, val=Example event sequence
   0.000257     [D5:61105] do_upsconf_args: call main_arg()
   0.000262     [D3:61105] main_arg: var='desc' val='Example event sequence'
   0.000265     [D5:61105] do_upsconf_args: confupsname=UPS1, var=port, val=evolution500.seq
   0.000267     [D5:61105] do_upsconf_args: call main_arg()
   0.000269     [D3:61105] main_arg: var='port' val='evolution500.seq'
   0.000272     [D6:61105] testinfo_reloadable: var=port, infoname=driver.parameter.port, newval=evolution500.seq, reloadable=0, reload_flag=0
   0.000290     [D6:61105] testinfo_reloadable: verdict for (re)loading var=port value: 1
   0.000298     [D5:61105] send_to_all: SETINFO driver.parameter.port "evolution500.seq"
   0.000318     [D5:61105] do_upsconf_args: confupsname=UPS2, var=driver, val=dummy-ups
   0.000340     [D5:61105] do_upsconf_args: confupsname=UPS2, var=desc, val=Example ePDU data dump
   0.000345     [D5:61105] do_upsconf_args: confupsname=UPS2, var=port, val=epdu-managed.dev
   0.000376     [D5:61105] do_upsconf_args: confupsname=UPS2, var=mode, val=dummy-once
   0.000385     [D1] Network UPS Tools version 2.8.2.1303.84-1387-g019529e68 (development iteration after 2.8.2) built with gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 and configured with flags: --enable-Wcolor --enable-warnings --enable-Werror --enable-keep_nut_report_feature --with-all=auto --with-cgi=auto --with-serial=auto --with-dev=auto --with-doc=skip --with-nut_monitor=auto --with-pynut=auto --disable-force-nut-version-header --enable-check-NIT --enable-maintainer-mode --disable-silent-rules --with-debuginfo=auto
   0.000391     [D1:61105] debug level is '6'
   0.000394     [D5:61105] send_to_all: SETINFO driver.debug "6"
   0.000414     [D5:61105] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.000496     [D1:61105] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000
   0.000534     [D5:61105] upsdrvquery_write: write to driver socket: NOBROADCAST

   0.000560     [D5:61105] upsdrvquery_write: write to driver socket: PING

   0.000583     [D5:61105] upsdrvquery_prepare: waiting for a while to flush server messages
sock_connect: enabling asynchronous mode (auto)
   0.162337     [D5:61105] upsdrvquery_read_timeout: received 5 bytes from driver socket: PONG

   0.162382     [D5:61105] upsdrvquery_prepare: got expected PONG
   0.162390     [D5:61105] upsdrvquery_prepare: ready for tracked commands
   0.162427     [D5:61105] upsdrvquery_write: write to driver socket: SET driver.flag.allow_killpower 1 TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263

   0.162471     [D5:61105] upsdrvquery_request: will wait up to 15.000000 sec for response to SET driver.flag.allow_killpower 1

   0.162626     [D5:61105] upsdrvquery_read_timeout: received 48 bytes from driver socket: TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263 0

   0.162668     [D5:61105] upsdrvquery_request: parsed out command status: 0
   0.162676     [D5:61105] upsdrvquery_close: closing driver socket, try to say goodbye
   0.162680     [D5:61105] upsdrvquery_write: write to driver socket: LOGOUT

   0.162742     [D5:61105] upsdrvquery_close: okay
   1.163005     [D5:61105] upsdrvquery_write: write to driver socket: NOBROADCAST

   1.163055     [D5:61105] upsdrvquery_write: write to driver socket: PING

   1.163061     [D5:61105] upsdrvquery_prepare: waiting for a while to flush server messages
sock_connect: enabling asynchronous mode (auto)
   2.163279     [D5:61105] upsdrvquery_read_timeout: received 5 bytes from driver socket: PONG

   2.163293     [D5:61105] upsdrvquery_prepare: got expected PONG
   2.163322     [D5:61105] upsdrvquery_prepare: ready for tracked commands
   2.163330     [D5:61105] upsdrvquery_write: write to driver socket: INSTCMD driver.killpower TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63

   2.163394     [D1:61105] upsdrvquery_request: will wait indefinitely for response to INSTCMD driver.killpower

Requesting UPS [UPS1] to power off, as/if handled by its driver by default (may exit), due to socket protocol request
   2.163430     select with socket: Invalid argument
   2.163451     [D5:61105] upsdrvquery_close: closing driver socket, try to say goodbye
instcmd: unknown command [shutdown.default] [(null)]
   2.163455     [D5:61105] upsdrvquery_write: write to driver socket: LOGOUT

UPS [UPS1]: shutdown request(s) failed
   2.163467     [D5:61105] upsdrvquery_close: okay
Signal -1: exiting
Can't connect to UPS [UPS1] (dummy-ups-UPS1): No such file or directory
   3.163624     [D1:61105] Socket dialog with the other driver instance: Invalid argument
   3.163681     [D5:61105] send_to_all: SETINFO device.type "ups"
   3.163688     [D5:61105] send_to_all: SETINFO driver.state "init.device"
   3.163720     [D2:61105] Dummy (simulation) mode with a sequence file name pattern (looping infinitely)
   3.163748     [D1:61105] Dummy (simulation) mode looping infinitely
   3.163777     [D5:61105] send_to_all: SETINFO driver.parameter.mode "dummy-loop"
   3.163819     [D2:61105] Located evolution500.seq for device simulation data: /home/jim/nut/tests/NIT/tmp/etc/evolution500.seq
   3.163849     [D5:61105] send_to_all: SETINFO driver.state "init.quiet"
   3.163875     Initiating UPS [UPS1] shutdown
   3.163885     [D1:61105] loop_shutdown_commands: call do_loop_shutdown_commands() with driver-default sdcommands
   3.163909     [D1:61105] Starting do_loop_shutdown_commands(shutdown.default), call depth 1...
   3.163914     [D1:61105] This driver does not implement INSTCMD support
   3.163939     [D1:61105] Handle 'shutdown.default' directly, ignore other `sdcommands` (if any): shutdown.default
   3.163944     shutdown not supported
   3.163948     [D1:61105] set_exit_flag: raising exit flag due to signal -1
   3.164000     [D1:61105] Ending do_loop_shutdown_commands(shutdown.default), call depth 1: return-code 0
   3.164026     UPS [UPS1]: shutdown request was successful with '(null)'
   3.164032     [D1:61105] set_exit_flag: raising exit flag due to programmatic abort: EXIT_FAILURE
   3.164037     [D5:61105] send_to_all: SETINFO driver.state "cleanup.upsdrv"
   3.164041     [D5:61105] send_to_all: SETINFO driver.state "cleanup.exit"
   3.164047     [D1:61105] upsnotify: notify about state NOTIFY_STATE_STOPPING with libsystemd: was requested, but not running as a service unit now, will not spam more about it
   3.164050     [D1:61105] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`
   3.164054     [D1:61105] upsnotify: failed to notify about state NOTIFY_STATE_STOPPING: no notification tech defined, will not spam more about it
   3.164057     [D1:61105] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`


:; ./clients/upscmd -u admin -p "$TESTPASS_ADMIN" -l "UPS1@localhost:$NUT_PORT"
Error: Driver not connected
  • Got a few wrinkles to investigate though, with instcmd: unknown command [shutdown.default] [(null)] and UPS [UPS1]: shutdown request was successful with '(null)' - maybe the tested system was from an older iteration though

@jimklimov
Copy link
Member Author

Sandboxing helped find some issues with upsdrvquery, fixed now (longer timestamp in log is from the running driver daemon, shorter is from drivername -k):

...
   0.000584     [D1:173231] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000
   0.000621     [D5:173231] upsdrvquery_write: write to driver socket: NOBROADCAST

   0.000647     [D5:173231] upsdrvquery_write: write to driver socket: PING

   0.000669     [D5:173231] upsdrvquery_prepare: waiting for a while to flush server messages
   0.000674     [D1:173231] upsdrvquery_read_timeout: tv={sec=3, usec=000000}
   8.009857     [D1:173190] entering parse_data_file()
   8.009910     [D1:173190] leaving (paused)...
   8.009924     [D5:173190] send_to_all: SETINFO driver.state "quiet"
   8.009985     [D6:173190] send_to_all: write 29 bytes to socket 5 succeeded (ret=29): SETINFO driver.state "quiet"

   8.010033     sock_connect: enabling asynchronous mode (auto)
   8.010044     [D3:173190] sock_connect: new connection on fd 6
   8.010081     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling NOBROADCAST with 1 args
   8.010087     [D1:173190] sock_arg: socket 6 requested NOBROADCAST mode
   8.010109     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling PING with 1 args
   8.010116     [D2:173190] send_to_one: sending PONG
   8.010121     [D5:173190] send_to_one: PONG
   8.010151     [D6:173190] send_to_one: write 5 bytes to socket 6 succeeded (ret=5): PONG

   0.097185     [D5:173231] upsdrvquery_read_timeout: received 5 bytes from driver socket: PONG

   0.097217     [D5:173231] upsdrvquery_prepare: got expected PONG
   0.097243     [D5:173231] upsdrvquery_prepare: ready for tracked commands
   0.097253     [D5:173231] upsdrvquery_write: write to driver socket: SET driver.flag.allow_killpower 1 TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263

   0.097298     [D5:173231] upsdrvquery_request: will wait up to 15.000000 sec for response to SET driver.flag.allow_killpower 1

   0.097307     [D1:173231] upsdrvquery_read_timeout: tv={sec=15, usec=000000}
   8.010314     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling SET with 5 args
   8.010328     [D3:173190] sock_arg: TRACKING = 2DDC5036-F665-4D29-BE4C-0374D091D263
   8.010334     [D2:173190] entering main_setvar(driver.flag.allow_killpower, 1) for [UPS1] on socket 6
   8.010369     [D1:173190] main_setvar: Setting driver.flag.allow_killpower=1
   8.010378     [D5:173190] send_to_all: SETINFO driver.flag.allow_killpower "1"
   8.010402     [D6:173190] send_to_all: write 40 bytes to socket 5 succeeded (ret=40): SETINFO driver.flag.allow_killpower "1"

   8.010425     [D2:173190] send_to_one: sending TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263 0
   8.010429     [D5:173190] send_to_one: TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263 0
   8.010467     [D6:173190] send_to_one: write 48 bytes to socket 6 succeeded (ret=48): TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263 0

   0.097501     [D5:173231] upsdrvquery_read_timeout: received 48 bytes from driver socket: TRACKING 2DDC5036-F665-4D29-BE4C-0374D091D263 0

   0.097546     [D5:173231] upsdrvquery_request: parsed out command status: 0
   0.097586     [D5:173231] upsdrvquery_close: closing driver socket, try to say goodbye
   0.097626     [D5:173231] upsdrvquery_write: write to driver socket: LOGOUT

   0.097696     [D5:173231] upsdrvquery_close: okay
   8.010698     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling LOGOUT with 1 args
   8.010747     [D2:173190] send_to_one: sending OK Goodbye
   8.010776     [D5:173190] send_to_one: OK Goodbye
   8.010805     [D6:173190] send_to_one: write 11 bytes to socket 6 succeeded (ret=11): OK Goodbye

   8.010826     [D2:173190] sock_arg: received LOGOUT on socket 6, will be disconnecting
   1.097967     [D5:173231] upsdrvquery_write: write to driver socket: NOBROADCAST

   9.010971     [D4:173190] sock_arg: LOGOUT processing finished
   9.011006     [D1:173190] sock_read: returning early, socket may be not valid anymore
   1.098017     [D5:173231] upsdrvquery_write: write to driver socket: PING

   9.011011     [D3:173190] sock_disconnect: disconnecting socket 6
   1.098023     [D5:173231] upsdrvquery_prepare: waiting for a while to flush server messages
   1.098027     [D1:173231] upsdrvquery_read_timeout: tv={sec=3, usec=000000}
   9.011027     [D5:173190] sock_disconnect: finishing parsing context
   9.011031     [D5:173190] sock_disconnect: relinking the chain of connections
   9.011063     [D5:173190] sock_disconnect: freeing the conn object
   9.011086     sock_connect: enabling asynchronous mode (auto)
   9.011132     [D3:173190] sock_connect: new connection on fd 6
   9.011172     [D5:173190] send_to_all: SETINFO driver.state "updateinfo"
   9.011245     [D6:173190] send_to_all: write 34 bytes to socket 6 succeeded (ret=34): SETINFO driver.state "updateinfo"

   1.098291     [D5:173231] upsdrvquery_read_timeout: received 34 bytes from driver socket: SETINFO driver.state "updateinfo"

   9.011320     [D6:173190] send_to_all: write 34 bytes to socket 5 succeeded (ret=34): SETINFO driver.state "updateinfo"

   9.011333     [D1:173190] upsdrv_updateinfo...
   1.098342     [D1:173231] upsdrvquery_read_timeout: tv={sec=3, usec=000000}
  10.011486     [D1:173190] entering parse_data_file()
  10.011537     [D1:173190] leaving (paused)...
  10.011549     [D5:173190] send_to_all: SETINFO driver.state "quiet"
  10.011608     [D6:173190] send_to_all: write 29 bytes to socket 6 succeeded (ret=29): SETINFO driver.state "quiet"

   2.098659     [D5:173231] upsdrvquery_read_timeout: received 29 bytes from driver socket: SETINFO driver.state "quiet"

  10.011663     [D6:173190] send_to_all: write 29 bytes to socket 5 succeeded (ret=29): SETINFO driver.state "quiet"

   2.098690     [D1:173231] upsdrvquery_read_timeout: tv={sec=2, usec=999999}
  10.011696     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling NOBROADCAST with 1 args
  10.011725     [D1:173190] sock_arg: socket 6 requested NOBROADCAST mode
  10.011734     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling PING with 1 args
  10.011763     [D2:173190] send_to_one: sending PONG
  10.011768     [D5:173190] send_to_one: PONG
  10.011793     [D6:173190] send_to_one: write 5 bytes to socket 6 succeeded (ret=5): PONG

   2.098821     [D5:173231] upsdrvquery_read_timeout: received 5 bytes from driver socket: PONG

   2.098897     [D5:173231] upsdrvquery_prepare: got expected PONG
   2.098923     [D5:173231] upsdrvquery_prepare: ready for tracked commands
   2.098933     [D5:173231] upsdrvquery_write: write to driver socket: INSTCMD driver.killpower TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63

   2.098977     [D1:173231] upsdrvquery_request: will wait indefinitely for response to INSTCMD driver.killpower

  10.011993     [D6:173190] sock_arg: Driver on /home/jim/nut/tests/NIT/tmp/run/dummy-ups-UPS1 is now handling INSTCMD with 4 args
   2.099007     [D1:173231] upsdrvquery_read_timeout: tv={sec=-1, usec=-00001} (unlimited timeout)
  10.012001     [D3:173190] sock_arg: TRACKING = 98C489FD-821C-4132-9D93-4F6590B55E63
  10.012015     [D2:173190] entering main_instcmd(driver.killpower, (null)) for [UPS1] on socket 6
  10.012021     Requesting UPS [UPS1] to power off, as/if handled by its driver by default (may exit), due to socket protocol request
  10.012047     [D5:173190] send_to_all: SETINFO driver.state "fsd.killpower"
  10.012075     [D6:173190] send_to_all: write 37 bytes to socket 5 succeeded (ret=37): SETINFO driver.state "fsd.killpower"

  10.012103     [D1:173190] loop_shutdown_commands: call do_loop_shutdown_commands() with driver-default sdcommands
  10.012108     [D1:173190] Starting do_loop_shutdown_commands(shutdown.default), call depth 1...
  10.012124     shutdown not supported
  10.012149     [D1:173190] set_exit_flag: raising exit flag due to signal -1
  10.012175     [D1:173190] do_loop_shutdown_commands(): command 'shutdown.default' was handled successfully
  10.012201     [D1:173190] Ending do_loop_shutdown_commands(shutdown.default), call depth 1: return-code 0
  10.012226     UPS [UPS1]: shutdown request was successful with 'shutdown.default'
  10.012252     [D1:173190] set_exit_flag: raising exit flag due to programmatic abort: EXIT_FAILURE
  10.012279     [D5:173190] send_to_all: SETINFO driver.state "quiet"
  10.012326     [D6:173190] send_to_all: write 29 bytes to socket 5 succeeded (ret=29): SETINFO driver.state "quiet"

  10.012351     [D2:173190] send_to_one: sending TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63 0
  10.012355     [D5:173190] send_to_one: TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63 0
  10.012391     [D6:173190] send_to_one: write 48 bytes to socket 6 succeeded (ret=48): TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63 0

   2.099414     [D5:173231] upsdrvquery_read_timeout: received 48 bytes from driver socket: TRACKING 98C489FD-821C-4132-9D93-4F6590B55E63 0

  10.012412     Signal -2: exiting
   2.099425     [D5:173231] upsdrvquery_request: parsed out command status: 0
  10.012420     [D1:173190] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`
   2.099428     [D5:173231] upsdrvquery_close: closing driver socket, try to say goodbye
  10.012458     [D5:173190] send_to_all: SETINFO driver.state "cleanup.upsdrv"
   2.099469     [D5:173231] upsdrvquery_write: write to driver socket: LOGOUT

  10.012483     [D6:173190] send_to_all: write 38 bytes to socket 5 succeeded (ret=38): SETINFO driver.state "cleanup.upsdrv"

   2.099496     [D5:173231] upsdrvquery_close: okay
  10.012492     [D5:173190] send_to_all: SETINFO driver.state "cleanup.exit"
  10.012526     [D6:173190] send_to_all: write 36 bytes to socket 5 succeeded (ret=36): SETINFO driver.state "cleanup.exit"

  10.012549     [D1:173190] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`
  10.012744     [D3:173190] sock_disconnect: disconnecting socket 6
  10.012776     [D5:173190] sock_disconnect: finishing parsing context
  10.012801     [D5:173190] sock_disconnect: relinking the chain of connections
  10.012806     [D5:173190] sock_disconnect: freeing the conn object
  10.012811     [D3:173190] sock_disconnect: disconnecting socket 5
  10.012848     [D5:173190] sock_disconnect: finishing parsing context
  10.012870     [D5:173190] sock_disconnect: relinking the chain of connections
  10.012874     [D5:173190] sock_disconnect: freeing the conn object
   3.099617     Request to killpower via running driver returned code 0
   3.099672     [D5:173231] send_to_all: SETINFO driver.state "cleanup.exit"
   3.099706     [D1:173231] upsnotify: notify about state NOTIFY_STATE_STOPPING with libsystemd: was requested, but not running as a service unit now, will not spam more about it
   3.099731     [D1:173231] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`
   3.099758     [D1:173231] upsnotify: failed to notify about state NOTIFY_STATE_STOPPING: no notification tech defined, will not spam more about it
   3.099786     [D1:173231] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`

So both copies of the driver program met, talked, and exited (with the daemon handling shutdown the best it could - no-op - and raising the exit flag).

jimklimov added a commit to jimklimov/nut that referenced this pull request Dec 2, 2024
…vate use of timeval={-1,-1} as select(..., NULL) for indefinite wait [networkupstools#1922, networkupstools#2392, networkupstools#2686]

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov merged commit 0727ce2 into networkupstools:master Dec 7, 2024
30 checks passed
@jimklimov jimklimov deleted the issue-2670 branch December 7, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature need testing Code looks reasonable, but the feature would better be tested against hardware or OSes service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USB HID UPS / APC HID UPS shutdown command attempted order
2 participants