commit 6577467acca3fd281273b95c3906a85dbf19e6f8
parent a9ac71ac2a874760466f673732610c2cc186797a
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Fri, 20 Apr 2018 15:32:05 +0000
Add -d notif to s6-svscan; this is only shallow readiness.
Diffstat:
5 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
@@ -1,5 +1,15 @@
Changelog for s6.
+In 2.7.2.0
+----------
+
+ - s6-ipcserver-socketbinder now takes a -B option to make the socket blocking.
+ - s6-svscan now takes a "-d notif" option to notify readiness. This is
+*shallow readiness*, i.e. readiness will be reported when s6-svscan is ready
+to receive s6-svscanctl commands; it does *not* mean all the services started
+at s6-svscan launch will be ready.
+
+
In 2.7.1.1
----------
diff --git a/doc/s6-svscan.html b/doc/s6-svscan.html
@@ -27,7 +27,7 @@ the root or a branch of a <em>supervision tree</em>.
<h2> Interface </h2>
<pre>
- s6-svscan [ -S | -s ] [ -c max ] [ -t <em>rescan</em> ] [ <em>scandir</em> ]
+ s6-svscan [ -S | -s ] [ -d <em>notif</em> ] [ -c max ] [ -t <em>rescan</em> ] [ <em>scandir</em> ]
</pre>
<ul>
@@ -62,6 +62,17 @@ execution. </li>
<li> <tt>-S </tt> : do not divert signals. This is the default for now;
it may change in a future version of s6. </li>
<li> <tt>-s </tt> : divert signals - see below. </li>
+ <li> <tt>-d <em>notif</em></tt> : notify readiness on file descriptor
+<em>notif</em>. When s6-svscan is ready to accept commands from
+<a href="s6-svscanctl.html">s6-svscanctl</a>, it will write a newline to <em>notif</em>.
+<em>notif</em> cannot be lesser than 3. By default, no notification is sent. Please
+note that using this option signals <em>shallow readiness</em>: s6-svscan being
+"ready" only means that it is ready to accept commands. It <em>does not mean</em>
+that all the services it launches at start are themselves ready, or even started, or
+even that the relevant <a href="s6-supervise.html">s6-supervise</a> processes have
+been started. If you need to test for <em>deep readiness</em>, meaning that all the
+services in the supervision tree have been started and are ready, you cannot rely
+on this option. </li>
<li> <tt>-c <em>max</em></tt> : maintain services for up to <em>max</em>
service directories. Default is 500. Lower limit is 2. There is no upper limit, but:
<ul>
diff --git a/doc/upgrade.html b/doc/upgrade.html
@@ -18,6 +18,15 @@
<h1> What has changed in s6 </h1>
+<h2> in 2.7.2.0 </h2>
+
+<ul>
+ <li> <tt>-B</tt> option added to
+<a href="s6-ipcserver-socketbinder.html">s6-ipcserver-socketbinder</a>. </li>
+ <li> <tt>-d <em>notif</em></tt> option added to
+<a href="s6-svscan.html">s6-svscan</a>. </li>
+</ul>
+
<h2> in 2.7.1.1 </h2>
<ul>
diff --git a/package/info b/package/info
@@ -1,4 +1,4 @@
package=s6
-version=2.7.1.1
+version=2.7.2.0
category=admin
package_macro_name=S6
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
@@ -5,6 +5,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
+#include <fcntl.h>
#include <signal.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
@@ -20,7 +21,8 @@
#include <s6/config.h>
#include <s6/s6-supervise.h>
-#define USAGE "s6-svscan [ -S | -s ] [ -c maxservices ] [ -t timeout ] [ dir ]"
+#define USAGE "s6-svscan [ -S | -s ] [ -c maxservices ] [ -t timeout ] [ -d notif ] [ dir ]"
+#define dieusage() strerr_dieusage(100, USAGE)
#define FINISH_PROG S6_SVSCAN_CTLDIR "/finish"
#define CRASH_PROG S6_SVSCAN_CTLDIR "/crash"
@@ -448,13 +450,14 @@ int main (int argc, char const *const *argv)
{
iopause_fd x[2] = { { -1, IOPAUSE_READ, 0 }, { -1, IOPAUSE_READ, 0 } } ;
int divertsignals = 0 ;
+ unsigned int notif = 0 ;
PROG = "s6-svscan" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
unsigned int t = 0 ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "Sst:c:", &l) ;
+ int opt = subgetopt_r(argc, argv, "Sst:c:d:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -462,7 +465,12 @@ int main (int argc, char const *const *argv)
case 's' : divertsignals = 1 ; break ;
case 't' : if (uint0_scan(l.arg, &t)) break ;
case 'c' : if (uint0_scan(l.arg, &max)) break ;
- default : strerr_dieusage(100, USAGE) ;
+ case 'd' :
+ if (!uint0_scan(l.arg, ¬if)) dieusage() ;
+ if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
+ if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
+ break ;
+ default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
@@ -501,6 +509,12 @@ int main (int argc, char const *const *argv)
if (selfpipe_trapset(&set) < 0) strerr_diefu1sys(111, "trap signals") ;
}
+ if (notif)
+ {
+ fd_write(notif, "\n", 1) ;
+ fd_close(notif) ;
+ notif = 0 ;
+ }
{
struct svinfo_s blob[max] ; /* careful with that stack, Eugene */