s6
Software
skarnet.org

The s6-notifyoncheck program

s6-notifyoncheck is a chain-loading program meant to be used in run scripts, in a service that has been declared to honor readiness notification. It implements a policy of running a user-provided executable in the background that polls the service currently being launched, in order to check when it becomes ready. It feeds the result of this check into the s6 notification mechanism.

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.

Interface

     s6-notifyoncheck [ -d ] [ -3 notiffd ] [ -s initialsleep ] [ -T globaltimeout ] [ -t localtimeout ] [ -w waitingtime ] [ -n n ] [ -c checkprog ] prog...

s6-notifyoncheck forks and runs as the child; the parent immediately execs into prog..., the daemon that must be checked for readiness.

s6-notifyoncheck first waits for a little time, then it 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. If ./data/check exits anything else, s6-notifyoncheck sleeps for a little time, then spawns ./data/check again. It loops until ./data/check succeeds, or 7 attempts fail, or a certain amount of time elapses.

Exit codes

s6-notifyoncheck can exit before executing into prog:

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:

Options

Usage

s6-notifyoncheck is designed to make it possible for services to use the s6 notification mechanism even with daemons that do not natively implement the mechanism of writing a newline to a file descriptor of their choice when they're ready.

Polling is evil. Please make sure you really have no other choice before writing a ./data/check program and using s6-notifyoncheck in 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.

If using a ./data/check program is your only option: