s6
Software
skarnet.org
The s6-notifywhenup program
Starting with s6-2.1.4.0, the s6-notifywhenup program has been deprecated,
because there was still a case (albeit extremely rare) where a race
condition would occur and readiness would be improperly advertised.
Readiness notification for a service can now be achieved via a
notification-fd file in the
service directory, containing the
number of the descriptor the service will write its readiness
notification newline to. The notification will directly be picked by
s6-supervise.
Quick upgrade recipe: for every service using s6-notifywhenup,
replace the s6-notifywhenup invocation in your run script with
fdmove 1 3, then perform echo 3 > notification-fd.
Done!
s6-notifywhenup launches a daemon while listening to a file descriptor,
and sends a 'U' event to a fifodir when it
receives something on that file descriptor.
This page explains why this program is
needed.
Interface
s6-notifywhenup [ -d fd ] [ -e fifodir ] [ -f ] [ -X ] [ -t timeout ] prog...
- s6-notifywhenup forks and executes prog... as the
parent, with a pipe from prog...'s stdout to the child.
- The child waits for a newline (\n) to be written
on the pipe. When it gets it, it creates a
./supervise/ready file then sends a 'U' event to the
./event fifodir.
- The child exits 0.
Options
- -d fd : listen to
prog's output on descriptor fd. The default is 1.
- -e fifodir : send a 'U' event to fifodir
fifodir. Default is ./event.
- -f : simple fork. Normally, s6-notifywhenup doubleforks,
in order to accommodate for a
prog that does not expect to have a child and avoid a
pending zombie. This option avoids the doublefork, but it should only be
set if prog reaps even children it doesn't know it has.
- -t timeout : if no EOF has been received
after timeout milliseconds, exit without sending the event.
Default is 0, meaning infinite.
- -X : fake readiness. s6-notifywhenup will actually send
the newline itself before executing prog. This option should in
principle never be used.
Notes
- s6-notifywhenup executes prog... as the parent in order
for prog to keep the same pid, which is vital for supervised
processes.
- s6-notifywhenup can be used, for instance, with
s6-ipcserver
and its -1 option, so that reliable startup notification is
achieved. s6-notifywhenup -f s6-ipcserver -1 args will
send a 'U' event to ./event when s6-ipcserver is actually
listening to its socket.
- The s6-svwait program can be used
to wait for 'U' events, as well as the
s6-svlisten1 and
s6-svlisten programs.
- The supervise/ready file, when created, contains at least
the absolute time when s6-notifywhenup detected service readiness. The
format and contents of this file are subject to change.