Re: patch: sv check should wait when svrun is not ready
There's no dependant service involved.
My check is running from outside the docker, racing against runit.
Your workaround is valid, but still a workaround. My patch obviates the
need for the workaround.
On Mon, Feb 16, 2015 at 3:56 PM, Colin Booth <cathexis_at_gmail.com> wrote:
> If you are running the sv check within a dependent service's run
> script that was spawned first, the script will fail and runsv will
> respawn it, with the call eventually succeeding once the required
> service is up. This presumes that you start your scripts set -e or
> /bin/sh -e of course, but there's no reason not to in this case.
>
> If you're calling this from a daemon script that is outside of the
> general supervision framework, you'll need to write a simple wait loop
> in shell to wrap the sv call similar to what Case suggested. Something
> like the following should do you:
>
> /bin/sh
> while ! sv check $REQSVC > /dev/null
> do echo "Waiting on required service $REQSVC"
> sleep 1
> done
>
> start_your_script_or_program_or_whatever
>
> But at that point, might as well just stick it into supervision and
> let the dependent run script fail a few times before check passes.
>
> Cheers!
>
> On Mon, Feb 16, 2015 at 1:23 PM, Buck Evan <buck_at_yelp.com> wrote:
> > Is there anything else I can do to get this considered for merge?
> >
> > On Mon, Feb 9, 2015 at 5:55 PM, Buck Evan <buck_at_yelp.com> wrote:
> >
> >> Essentially, if `sv check` is run too soon after `runsv` (or runit for
> >> that matter), it will immediately fail without waiting for runsv to come
> >> up. In my particular use case, runit is running inside a (detached)
> docker,
> >> and I'm using `sv check` to wait for my dockerized service to be ready,
> >> which I think is a good use case for `sv check`. Without this patch, I'm
> >> forced to write some code which re-runs `sv check` if it fails before
> >> $SVWAIT seconds, which sounds awfully like the behavior of sv-check
> itself.
> >>
> >>
> >> You can demonstrate the problem I'm trying to describe like so:
> >>
> >> #!/bin/bash
> >> make
> >> rm -rf myservice
> >> mkdir -p myservice
> >> ln -s /bin/cat myservice/run
> >> ./runsv ./myservice/ >&/dev/null & ./sv check ./myservice/; echo $?;
> ./sv
> >> check ./myservice/; echo $?
> >>
> >>
> >> Output:
> >>
> >> $ ./demo
> >> warning: ./myservice/: unable to open supervise/ok: file does not exist
> >> 1
> >> ok: run: ./myservice/: (pid 65635) 0s
> >> 0
> >>
> >>
> >> Patch:
> >>
> >> --- src/sv.c
> >> +++ src/sv.c
> >> _at__at_ -213,7 +213,7 @@ int checkscript() {
> >> int check(char *a) {
> >> unsigned int pid;
> >>
> >> - if ((r =svstatus_get()) == -1) return(-1);
> >> + if ((r =svstatus_get()) == -1) return(0);
> >> while (*a) {
> >> if (r == 0) { if (*a == 'x') return(1); return(-1); }
> >> pid =(unsigned char)svstatus[15];
> >>
> >>
>
>
>
> --
> "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 Tue Feb 17 2015 - 01:08:18 UTC
This archive was generated by hypermail 2.3.0
: Sun May 09 2021 - 19:44:19 UTC