Re: detect service crashes

From: Charlie Brady <charlieb-supervision_at_budge.apana.org.au>
Date: Fri, 6 Sep 2013 10:16:15 -0400 (EDT)

On Fri, 6 Sep 2013, Alex Efros wrote:

> tail ./log/current | mail "$USER" -s "service exit: $(basename "$(pwd)")"
>
> I'm using this in many of our custom services, and it's very useful.
> But I'm also receiving a lot of useless emails every time server rebooted
> or services restarted manually.
>
> Is it possible to somehow detect in ./finish script is it was called
> because ./run just exited/crashed on it's own, or because ./run was killed
> by `sv t` (manually) or `sv force-stop` (while server shutdown)?

See runsv's man page:


 Two arguments are given to ./finish. The first one is ./runs exit code,
 or -1 if ./run didnt exit normally. The second one is the least significant
 byte of the exit status as determined by waitpid(2); for instance it is 0
 if ./run exited normally, and the signal number if ./run was terminated by
 a signal. If runsv cannot start ./run for some reason, the exit code is
 111 and the status is 0.
Received on Fri Sep 06 2013 - 14:16:15 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:18 UTC