supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Charlie Brady <charlieb-smarden-supervision@budge.apana.org.au>
Cc: supervision@list.skarnet.org
Subject: Re: Who actually gets the TERM signal in "runsvctrl down"?
Date: Fri, 25 Jun 2004 22:17:49 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0406252150440.2967-100000@e-smith.charlieb.ott.istop.com> (raw)
In-Reply-To: <m3brj7f67z.fsf@asfast.com>


On Fri, 25 Jun 2004, Lloyd Zusman wrote:

> That's like coding for the purpose of maintaining vaporware ... and
> conjectured vaporware, at that. :)

Now you wouldn't do that, would you?

> However, there's another problem that I need to solve.  In the script
> that I posted in my earlier message, you can see that I do a cleanup of
> certain directories when I do a "start" and a "restart" before actually
> starting the daemon.  But I don't want that cleanup to be done during
> the "graceful" command, which is consistent with its semantics.
> 
> That means that my "run" script would have to tell the difference
> between "restart" and "graceful", and the only way I can see to do this
> in a runit/daemontools environment is to trap the differing signals in
> the script ... 

No.

When you do:

runsvctrl 1 httpd

then the httpd process gets SIGUSR1 (directly) and behaves just as if
you'd typed "httpd -k graceful". Your run script doesn't enter into it -
hopefully it is not running, and has gone away long ago (when it exec'd
httpd).

When you do:

runsvctrl t httpd

then the httpd process gets TERM, and goes through its shutdown process, 
eventually waiting for its children to die, then it exits. Then runsv 
starts up a new instance of your run script, which does the cleanup, then 
execs the new httpd.

> something like this:

No. You're making it complicated. Unnecessarily.

> This situation could occur in any daemon where there are
> installation-specific functions that need to be performed depending on
> whether the daemon is being started, stopped, restarted, etc.
> 
> How can we handle this in the general case?

Being started and being restarted are both covered by what is done in the 
run script. If you need something special done when you stop a daemon 
(which usually is not the case), then with runit you can provide a 
"finish" script.

> > Right - in the general case, we write replacements to make it work. :)
> 
> Yes, we can always write replacements in these cases.  But given the
> situation I described above, the replacements we write for certain
> daemons might have to involve the trapping of the signals that are
> sent by svc/runsvctrl.

Very, very rarely. And not in this case, as far as I've seen.

> > The issue isn't the extra time, it's the inability to send signals
> > reliably.  ("httpd -k stop" almost certainly uses a pid file, which
> > can be out of date.)
> 
> Ah ... yes, that's true.
> 
> So given that drawback, how should we solve the problem that I outlined
> above?

See my various earlier messages. 

All you need to do is create a suitable run script. Perhaps something
like:

#! /bin/sh
exec 2>&1
do_your_cleanup_stuff
TZ=xxxxx exec chpst -P /usr/sbin/httpd -DNO_DETACH

graceful:

runsvctrl 1 httpd ; runsvctrl u httpd

stop:

runsvctrl d httpd

start:

runsvctrl u httpd

restart:

runsvctrl t httpd ; runsvctrl u httpd

Einstein: Things should be made as simple as possible - but no simpler.

---
Charlie



  reply	other threads:[~2004-06-26  2:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-25 14:01 Lloyd Zusman
2004-06-25 15:33 ` Charlie Brady
2004-06-25 16:03   ` Lloyd Zusman
2004-06-25 16:11     ` Charlie Brady
2004-06-25 16:36       ` Lloyd Zusman
2004-06-25 17:15         ` Paul Jarc
2004-06-26  0:26           ` Scott Gifford
2004-06-26  1:39           ` Lloyd Zusman
2004-06-26  2:17             ` Charlie Brady [this message]
2004-06-26  2:44               ` Lloyd Zusman
2004-06-26  3:01                 ` Lloyd Zusman
2004-06-26  4:03                   ` Lloyd Zusman
2004-06-26  8:17                     ` Thomas Schwinge
2004-06-26 15:45                     ` Charlie Brady
2004-06-25 18:27         ` Charlie Brady
2004-06-25 19:13           ` Lloyd Zusman
2004-06-25 19:48             ` Charlie Brady
2004-06-26  3:49             ` Paul Jarc
2004-06-26 21:10               ` Lloyd Zusman
2004-06-25 18:40     ` Jim Zajkowski
2004-06-25 16:13   ` Dean Hall
2004-06-25 16:17     ` Charlie Brady

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0406252150440.2967-100000@e-smith.charlieb.ott.istop.com \
    --to=charlieb-smarden-supervision@budge.apana.org.au \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).