Hi Laurent,
Thanks for adding the readiness support to s6. Finally had a chance
to work with it a bit.
My current use case is upgrading a service on N host machines in
a rolling fashion, where the service is deployed to one machine,
restarted, and when it reports that it's ready, the process is
repeated on the remaining machines. If anything runs afoul, manual
intervention is the solution.
The upgrade script runs:
s6-svc -Dt /service/s && s6-swait -U /service/s
The /service/s/log/run script includes this fragment:
pipeline -w
{
cd ..
loopwhilex
s6-notifywhenup
s6-setuidgid nobody
backtick R { head -n1 } import R if { test -n $R } echo 1
}
s6-setuidgid nobody
s6-log
- +${REGEX} 1
...
So, the loopwhilex and s6-notifywhenup runs as root, but everything
else as nobody.
The backtick command is the simplest thing I came up with that reads
one line from stdin, writes a newline to stdout (for s6-notifywhenup),
exiting 0, or exiting nonzero if nothing but EOF is read (which
causes loopwhilex to exit as well, when s6-log exits).
I wanted to use 's6-notifywhenup' rather than manually touching the
ready
file and sending the U event.
${REGEX} matches a special log line that indicates the service is ready.
The loopwhilex keeps the pump primed, so to speak, so /service/s can
be stopped and started many times with readiness reporting working.
Otherwise, I'd need to restart /service/s/log as well as /service/s.
On the other hand, I have mostly idle backtick and head commands hanging
around.
--
Patrick Mahoney <pat_at_polycrystal.org>
Received on Wed Feb 25 2015 - 21:29:37 UTC