Autore: Isaac Dunham Data: To: Laurent Bercot CC: dng Oggetto: Re: [Dng] Readiness notification
On Mon, Jun 15, 2015 at 01:14:51AM +0200, Laurent Bercot wrote: > On 15/06/2015 00:36, Isaac Dunham wrote:
> >I think that a program that must run in the background is broken.
> >Yet *prohibiting* auto-backgrounding imposes an even more heavy toll
> >on scripts where <process 1> requires <process 2> to be running and
> >ready: you *must* run a supervisor, or else run a lame-not-quite-a-
> >supervisor, just to do what would have been trivially done in a few
> >more lines of C.
>
> Can you please elaborate or reformulate ? I don't understand what you
> mean. I don't think there's *ever* a case where it is necessary for
> the original process to die, so what is the kind of script you are
> thinking of ? Could you give a small example ?
> (We should take this to the supervision list, this is becoming
> seriously off-topic for dng.)
Consider the case where you want a script that
a) starts a server
b) runs a client that accesses that server in the foreground
The client will send the server the message to terminate, or
we can use a few other ways to watch.
This could be a test script, qemu as a vpnc server, or any of a hundred
other applications.
The application I immediately think of is running a non-graphical qemu
build (Alpine Linux choices...) with a vpnc client.
I wanted a local script that I could use like plain old graphical qemu,
on my old netbook (where running two instances of qemu is going to be
off-limits due to crappy hardware).
Possible solutions:
(1) Backgrounding manually, as recommended for scripts by the site you mentioned.
(1a) Error-prone: sometimes, client starts too soon
server &
client
(1b) Usually works, but doesn't connect ASAP:
server &
sleep 5
client
(2) Server auto-backgrounds:
server -B
client
(3) Server uses "not-a-supervisor":
# write a small C wrapper that forks, execs server in child,
# accepts s6-style notification and exits in parent
fake-sv -d 1 server
client
(4) Server with s6, as far as I can tell from the skarnet docs:
# Upgrade GNU make to 4.0 & build skalibs
# Build execline
# Build s6
# Create a service directory for server, containing a run file like this:
server
# Launch it, via s6-svscan or s6-supervise
# Wait and exit:
s6-svwait -U servicedir
client