>if s6-svstat myserver; then
> client_binary
>else
> send_email_to_admin
> faux_client_binary
>fi
Please don't do this.
- As Steve would be able to tell you if he had read the documentation
page for s6-svstat (
https://skarnet.org/software/s6/s6-svstat.html),
"s6-svstat myserver"'s exit code does not mirror whether myserver is
running or not. If myserver is a live service directory, s6-svstat
will print a line to stdout summarizing the status of the service,
then exit 0. Zero, even if the service is down, so client_binary
will fail.
s6-svstat will only exit nonzero if an error occurs or if no
supervisor is running on myserver, which is not what this script
aims to test.
- It is good to notify the admin when something on the system is not
working correctly. Doing it automatically from a script, however, is
not a good idea. Spamming the admin's mailbox via automated messages
is an great way to get yourself ignored at best (which defeats the
purpose of reporting bugs) or banned at worst.
- If you're using s6, as I said earlier, you're supposed to be able
to assume that myserver is running, and you don't have to write
such wrappers, even ones that would work.
--
Laurent
Received on Thu Jan 12 2023 - 01:51:24 CET