SIGPWR interrupt - upstart init with powstatd UPS daemon
Scott James Remnant
scott at netsplit.com
Fri Feb 16 10:25:12 GMT 2007
On Thu, 2007-02-15 at 18:04 -0800, Will Dickson wrote:
> Hi, I've been trying to get powstatd to work with the upstart init
> program on ubuntu edgy and have been having some difficulties. I
> verified that powstatd is performing correctly - i.e., when the power
> to the UPS is cut powstatd changes the entry in /etc/powerstatus from OK
> to FAIL and sends a SIGPWR interrupt to init. Init is then suppose to
> check the entry in /etc/powerstatus etc. However, I couldn't seem to get
> the upstart init to respond to the SIGPWR interrupt.
>
Right, I never included the SIGPWR code in init because I didn't know
whether it was still used or not.
> I grepped around in the upstart-0.3.5 sources and couldn't find any
> handlers for SIGPWR. Whereas the sysvinit does have a handler for SIGPWR
> Am I missing something? Is there a way to make the upstart init work
> with the UPS daemons?
>
The attached patch and job file should do the trick; after installing,
you should be able to write jobs with:
start on power-status fail
start on power-status low
start on power-status ok
in them.
Please let me know whether this works, so I can commit it.
In the longer term, powstatd should emit its own upstart events instead
of sending a signal -- that provides for a lot more flexibility; e.g.
you could emit a "power-level" event every time the battery charge
decreased by 5%, etc.
Scott
--
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SIGPWR.patch
Type: text/x-patch
Size: 2696 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/upstart-devel/attachments/20070216/1de29fe0/attachment-0001.bin
-------------- next part --------------
description "Handle changes to the /etc/powerstatus file"
author "Scott James Remnant"
start on power-status-changed
script
PWRSTATUS=$(cat /etc/powerstatus)
if [ $PWRSTATUS = "OK" ]; then
initctl emit power-status ok
elif [ $PWRSTATUS = "FAIL" ]; then
initctl emit power-status fail
elif [ $PWRSTATUS = "LOW" ]; then
initctl emit power-status low
fi
end script
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/upstart-devel/attachments/20070216/1de29fe0/attachment-0001.pgp
More information about the upstart-devel
mailing list