S6-NOTIFYONCHECK(8)
π¦ s6-notifyoncheck β the "is it ready yet??" bestie of s6 (section 8, System Manager's Manual)
okay so picture this: you've got a daemon that has no idea how to tell s6 "hey girl I'm ready π
", but it does answer if you poke it from the outside. s6-notifyoncheck is literally the friend who pokes it for you, over and over, until it finally says yes β and then she runs and tells s6 the good news. That's the whole vibe. β¨
πΈ SYNOPSIS πΈ
s6-notifyoncheck [-d] [-3 notiffd] [-s initialsleep] [-T globaltimeout]
[-t localtimeout] [-w waitingtime] [-n n]
[-c checkprog] prog...
π DESCRIPTION π
s6-notifyoncheck is a chain-loading program β meaning it slots itself into your run script, does its little job, and then hands the whole thing off. It's meant for a service that has already been declared to honor readiness notification. π
π¨ real talk: s6-notifyoncheck should only be used with daemons that can be polled from the outside to check readiness and that do not implement readiness notification themselves. Both conditions. No exceptions, bestie.
So here's the choreo: s6-notifyoncheck forks and runs as the child; the parent immediately execs into prog..., which is the daemon that must be checked for readiness. Like, zero hesitation, she's gone.
Then s6-notifyoncheck first waits for a little time (yes, a little vibe check pause π·), then spawns the ./data/check executable and waits for it to exit. If ./data/check exits 0, then s6-notifyoncheck reports that the service is ready, then exits. Slay. If ./data/check exits anything else, s6-notifyoncheck sleeps for a little time, then spawns ./data/check again. And it loops β until ./data/check succeeds, or 7 attempts fail, or a certain amount of time elapses. π
s6-notifyoncheck exists so that services can use the s6 notification mechanism (cf. s6-notifywhenup(7)) even with daemons that do not natively implement the whole "write a newline to a file descriptor of their choice when they're ready" thing. She's basically the translator in the group chat. π«Ά
π Polling is evil[1]. Please make sure you really have no other choice before writing a./data/checkprogram and usings6-notifyoncheckin your run script. If you have access to the source code of the daemon you want to check for readiness, consider patching it to add readiness notification support β which is extremely simple and does not require linking against any s6 library. fr fr, it's easier than you think.
If using a ./data/check program is your only option:
- Make sure the
./datasubdirectory is readable and that./data/checkis executable, exits0if the daemon it checks is ready, and exits nonzero if the daemon is not ready. β - Add a
./notification-fdfile to your service directory, which can contain any number that is not0,1or2, or anything else explicitly used in your run script. The daemon does not need to care about that file descriptor; from the daemon's point of view, nothing changes. Like, it literally doesn't even know. π - In your run script, insert
s6-notifyoncheckin the command line that will execute into your daemon. ./data/checkwill run as the same user ass6-notifyoncheck. Ifs6-notifyoncheckruns after the run script's process has lost its root privileges, make sure that./data/checkis accessible and runnable as that user. π- Note that
s6-notifyoncheckshould be used to check if the current service itself is running. You cannot use it to poll for the readiness of another service. Not her job, not her lane. π s6-notifyoncheckmust be run with the service directory as its current working directory. In other words: you cannot useβcdβin your run script before you execute the command line containings6-notifyoncheck(else you will get a weird error message saying the supervisor is not running). If your service needs to run in a different working directory, you need to change working directories after thes6-notifyoncheckinvocation. Thecd(1)utility from the execline[2] package can be used to change working directories in the middle of a command line (and exec the rest of the command line) without invoking a shell. π§
β¨ OPTIONS β¨
-dβ Doublefork.s6-notifyoncheckwill run as the grandchild ofprog...instead of its direct child. This is useful ifprog...never reaps zombies it does not know it has. π§ (yes, actual zombie management, iconic)-3notiffd β Use notiffd as the file descriptor to send a readiness notification to. By default, this number is automatically read from the./notification-fdfile. π¬-sinitialsleep β Sleep for initialsleep milliseconds before starting to poll the service for readiness. Default is10milliseconds. π΄-Tglobaltimeout β Give up (and leave the service up but not ready) if service readiness still has not been detected after globaltimeout milliseconds. Default is0, meaning infinite:s6-notifyoncheckwill keep polling until it succeeds. β³-tlocaltimeout β On every attempt, if./data/checkstill has not exited after localtimeout milliseconds, kill it and declare that attempt failed. Default is0, meaning infinite:s6-notifyoncheckwill wait forever for./data/checkto exit. πͺ-wwaitingtime β Sleep for waitingtime milliseconds between two invocations of./data/check. This is basically the polling period. Default is1000: the service will be polled every second. π°οΈ-nn β Give up after n unsuccessful invocations of./data/check.0means infinite, i.e. keep polling until it succeeds, or times out, or the service dies first. Default is7. 7οΈβ£-ccheckprog... β Invoke checkprog... instead of./data/check. The checkprog string will be parsed byexeclineb(1), so it can contain a full command line. This option is mainly useful is the program used to poll the service is very simple and can be inlined as a simple command line, to avoid needing to manage a whole script and a./data/checkfile. This option is only supported if the execline[2] package is installed; if it is not, the-coption cannot be used and the checking script must always be placed in./data/check. π
π EXIT STATUS π
s6-notifyoncheck can exit before executing into prog:
100β Wrong usage. π111β System call failed. π
After forking, s6-notifyoncheck (running as the child) can exit with the following exit codes, but those are meaningless because no process will, or should, check them. They are only differentiated for clarity in the code:
0β Service readiness achieved and notification sent. π1β Maximum number of attempts reached, all unsuccessful. π2βprogdied, sos6-notifyoncheckexited early. β°οΈ3β Timed out before readiness was achieved. β111β System call failed. π
π SEE ALSO π
execlineb(1), s6-permafailon(8), s6-supervise(8), s6-svc(8), s6-svdt(8), s6-svdt-clear(8), s6-svlisten(8), s6-svlisten1(8), s6-svok(8), s6-svscan(8), s6-svscanctl(8), s6-svstat(8), s6-svwait(8)
This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/s6-notifyoncheck.html
π«Ά AUTHORS π«Ά
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port)
and that's the whole page, bestie β no cap, every flag accounted for π
Sending you off with love from Debian, dated April 16, 2024, source S6-NOTIFYONCHECK(8) β go forth and poll responsibly, and remember: polling is evil π₯πΈβ¨
π¦ where this page comes from
- nixpkgs unstable: s6 2.15.1.0
- nixpkgs unstable: s6-man-pages 2.14.0.1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms