Browse Source

Add S6_SERVICES_READYTIME

Signed-off-by: Laurent Bercot <[email protected]>
Laurent Bercot 3 years ago
parent
commit
94ba8e04c2

+ 8 - 0
README.md

@@ -814,6 +814,14 @@ wait, at shutdown time, for a script in `/etc/cont-finish.d` to finish naturally
 duration, the script will be sent a SIGKILL. Bear in mind that scripts in `/etc/cont.finish.d`
 are run sequentially, and the shutdown sequence will potentially wait for `S6_KILL_FINISH_MAXTIME`
 milliseconds for *each* script.
+* `S6_SERVICES_READYTIME` (default = 5): With services declared in `/etc/services.d`, there is
+an unavoidable race condition between the moment when services are started and the moment when
+they can be tested for readiness. To avoid that race, we sleep a little time, by default 5
+milliseconds, before testing for readiness. If your machine is slow or very busy, you may
+get errors looking like `s6-svwait: fatal: unable to s6_svstatus_read: No such file or directory`.
+In that case, you should increase the sleeping time, by declaring it (in milliseconds) in the
+`S6_SERVICES_READYTIME` variable. Note that it only concerns `/etc/services.d`; s6-rc is immune
+to the race condition.
 * `S6_SERVICES_GRACETIME` (default = 3000): How long (in milliseconds) `s6` should wait,
 at shutdown time, for services declared in `/etc/services.d` to die before proceeding
 with the rest of the shutdown.

+ 5 - 1
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/services-up

@@ -39,8 +39,12 @@ if dowait=`printcontenv S6_CMD_WAIT_FOR_SERVICES` && s6-test "$dowait" =~ '^[[:d
     maxtime=0
   fi
 
+  if rtime=`printcontenv S6_SERVICES_READYTIME` && s6-test "$rtime" =~ '^[[:digit:]]+$' ; then : ; else
+    rtime=5
+  fi
+
   # Increase if necessary. Unavoidable race condition, use s6-rc instead!
-  s6-sleep -m 5
+  s6-sleep -m "$rtime"
 
   r=false
   if test -n "$notifno" && ! s6-svwait -u -t "$maxtime" -- $notifno ; then