-
-
Notifications
You must be signed in to change notification settings - Fork 397
Description
I'm struggling with configuring secondary systems based on Windows. I've successfully installed NUT-Windows from release page (2.8.4) as Windows Service. NUT service is configured to be netclient. upsmon is able to read config file successfully but shutdown design doesn't work as expected
I have RPi (CentOS Stream 9, NUT 2.8.3) as primary UPS controller and a bunch of secondary systems (Windows 7, 10 etc; NUT 2.8.4). Secondary systems drive heavy equipment which should be parked properly before shutdown. My plan is to use NUT as netclient just to catch FSD event on primary UPS and then execute equipment-specific script with consequent shutdown. For the test purposes I've created simple bash script which just emulates long shutdown process:
#!/usr/bin/bash
# as for now I'm using Cygwin for quick tests
DT=`date`
echo "SHUTDOWN at ${DT}" >> /cygdrive/c/nut/history.log
sleep 900 # we're emulating long process here; on real system here will be equipment-specific incantation
/cygdrive/c/Windows/System32/shutdown.exe /s /t 5
exit 0
On primary system I've set HOSTSYNC to the number just a bit higher than required to properly shut down secondaries (1200). On the secondaries I have SHUTDOWNEXIT set to -1 (also tried false and even big numbers like 2000). According to the docs primary upsmon should wait until all secondaries disconnect (which should occur because I'm requesting Windows shutdown at the end of the process) and only then switch off itself and controlled UPS. However Windows logs tell me that secondary upsmon quits right after its FINALDELAY count of seconds which means two things: executing of SHUTDOWNCMD doesn't wait for it; SHUTDOWNEXIT flag is ignored at all. Otherwise upsmon should live until Windows is powered off even in case of non-blocking system() call in upsmon code.
I'm not sure if this is something special for Windows systems. As for me it looks like the only way to implement required shutdown design is to set FINALDELAY on primary to the big enough number which guarantees that even the longest shutdown process among secondaries will end properly. But in that case I'm forced to wait predefined number of seconds even if shutdown of secondaries will complete even earlier.
May be someone could point me in the right direction...