s6 readiness support

From: Patrick Mahoney <pat_at_polycrystal.org>
Date: Wed, 25 Feb 2015 15:29:37 -0600

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 ..
         s6-setuidgid nobody
         backtick R { head -n1 } import R if { test -n $R } echo 1

   s6-setuidgid nobody
     - +${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
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

Patrick Mahoney <pat_at_polycrystal.org>
Received on Wed Feb 25 2015 - 21:29:37 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC