Autor: poitr pogo Data: Dla: Isaac Dunham CC: dng Temat: Re: [Dng] Why daemontools is so cool
On Sat, Mar 28, 2015 at 4:15 PM, Isaac Dunham <ibid.ag@???> wrote:
(...) > If you want to *manage* a daemon (ie, do something when it stops, like
> restarting it), it's very tricky to do it reliably without having a fixed
It might be tricky if application does not support startup/shutdown procedure.
That's why I would expect application to provide a script to start/stop it.
I expect application to be tested on a system it is to be running on,
so developing a stop/start script is not a big deal comparing to the
whole test procedure.
> PID; "daemonizing" means close stdin/stdout/stderr, then
> if (fork()) exit(0);
> or some such thing (in other words, create a new process and exit the
> old one), so you do not have a fixed PID.
>
> On Linux, BSD, and older UNIX versions, this can be done thus:
> daemon(0,0);
>
How this can be done in java? ;)
Detaching from terminal, binding to reserved ports, dropping privileges, etc.
>> Another s6 limitation - finish script must end in 3 seconds. or will be killed.
>> Nice for desktop, not a server.
>
> sysvinit /etc/init.d/sendsigs actually only allows 1 second.
>
I see it is skipping some processes (which have their own upstart
scripts, and others which are recorded in special file not to be
killed by sendsigs). So it (sendsigs) is for all the rest of processes
which do not care about how they should be stopped. Not for that which
provide its own start/stop scripts.
In case of s6 it is the limit for the finish script for particular application.
(...) >
> My understanding is that s6 and some of the equivalent packages, such
> as daemontools, are fairly portable.
>
> They are generally not used as a way to offload daemonizing, but as a
> way to ensure that a service stays started. If you don't need that,
> you don't need them.
>
s6 advertises itself as init replacement.
I'm not using s6 or daemontools. I do not need them. Just learned
about them and I'm bit surprised thy tend to replace init instead of
being a good helpers for those who need them.
IMHO they came into existence cause more and more applications were
missing "deamon" part, to make sysadmin/programmer life easier. s6 doe
not support those which daemonize on its own, anyway :)
init has inittab for monitoring application which need continuous
restart by design like getty.
If a daemon needs to be monitored and restarted when it dies, bug
should be fixed.
I expect a deamon to work from start to stop command. No self stopping.
As workaround nohup, screen, while `true`,etc are enough to keep
system running until bug is fixed.
I do not like buggy software, so maybe that's why i do not need s6/daemontools.