Uninterruptible power supply: Difference between revisions
update |
done |
||
| Line 193: | Line 193: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
= The Delayed UPS Shutdown = | |||
As part of the system shutdown process, there needs to be an action to | |||
send a message to the UPS to tell it that some time later, it too will | |||
shut down. Note that the UPS does not shutdown at the same time as the | |||
system it protects. The UPS shutdown is delayed. By default the delay | |||
is 20 seconds. The absence of AC power to the protected system for a | |||
sufficient time has the effect of resetting the BIOS options, and in | |||
particular the option Restore power on AC return. This BIOS option | |||
will be needed to restart the box. | |||
During the system shutdown, systemd service unit runs the command | |||
upsdrvctl shutdown. This tells the UPS that it is to shut down | |||
offdelay seconds later. The system powers down before offdelay seconds | |||
have passed. Wall power returns before the UPS shuts down Less than | |||
offdelay seconds have passed. The UPS continues it's shutdown | |||
process. | |||
After offdelay seconds the UPS shuts down, disconnecting it's | |||
outlets. The beeping stops. With some UPS units, there is an audible | |||
clunk. An interval of ondelay-offdelay seconds later: After ondelay | |||
seconds the UPS turns itself on, and repowers it's outlets. The system | |||
BIOS option Restore Power on AC return has hopefully been selected and | |||
the system powers up. | |||
<syntaxhighlight lang="nix"> | |||
# copied from ConfigExamples 3.0 book, Appendix B.2. | |||
systemd.services.nut-delayed-ups-shutdown = { | |||
unitConfig = { | |||
Description = "Initiate delayed UPS shutdown"; | |||
Before = "umount.target"; | |||
DefaultDependencies = false; | |||
}; | |||
serviceConfig = { | |||
Type = "oneshot"; | |||
ExecStart = ''${pkgs.bash}/bin/bash -c\ | |||
"${pkgs.util-linux}/bin/logger -t\ | |||
nut-delayed-ups-shutdown 'upsdrvctl shutting down UPS';\ | |||
${pkgs.nut}/bin/upsdrvctl shutdown"''; | |||
}; | |||
wantedBy = "final.target"; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||