Re: s6: something like runit's ./check script

From: Colin Booth <cathexis_at_gmail.com>
Date: Wed, 16 Sep 2015 22:21:07 -0700

I think I've found what should be the cannonical timered ./check
equivalent script.
On Tue, Sep 8, 2015 at 9:29 AM, Buck Evan <buck_at_yelp.com> wrote:
Original normalized versions:
>
> Laurent's:
> #!/command/execlineb -P
> background -d
> {
> fdmove 1 3
> forx -x 0 dummy { 1 2 3 4 5 6 7 }
> ifelse { ./check } { echo }
> foreground { sleep 1 }
> exit 1
> }
> fdclose 3
> ./run.real
>
> Colin's:
> #!/command/execlineb -P
> fdmove -c 2 1
> background -d
> {
> fdmove 1 3
> loopwhilex -o 1
> ifelse { ./check } { echo }
> foreground { sleep 1 }
> exit 1
> }
> fdclose 3
> ./run.real
>

It's a hybrid of the above two scripts, and gets around the limitation
of forx needing an entry for each timer step:
#!/command/execlineb -P
fdmove -c 2 1
background -d
{
  fdmove 1 3
  s6-envdir env
  import TIMER
  s6-maximumtime $TIMER
  loopwhilex -o 1
  ifelse { ./check } { echo }
  foreground { sleep 1 }
  exit 1
}
fdclose 3
./run.real

That will give you an easily adjustible amount of wait time before
./check is considered a failure while still not sleeping forever. This
obviously requires envdir ./env to contain a file TIMER with the wait
timout in milliseconds and at least with the current implementation of
s6-maximumtime doesn't allow for an easily defined unlimited sleep
period. Besides that though, it's probably the best of both worlds.

Laurent, would you consider changing s6-maximumwait to accept 0 as
"fork and wait forever"?

Cheers!



-- 
"If the doors of perception were cleansed every thing would appear to
man as it is, infinite. For man has closed himself up, till he sees
all things thru' narrow chinks of his cavern."
  --  William Blake
Received on Thu Sep 17 2015 - 05:21:07 UTC

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