supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Gerrit Pape <pape@smarden.org>
To: supervision@list.skarnet.org
Subject: Re: How to kill runsv, no matter what?
Date: Fri, 23 Feb 2007 14:05:03 +0000	[thread overview]
Message-ID: <20070223140504.17459.qmail@3f646761ee1f68.315fe32.mid.smarden.org> (raw)
In-Reply-To: <5422d5e60702221951h1abb7e60l77717192900a63a8@mail.gmail.com>

On Thu, Feb 22, 2007 at 10:51:50PM -0500, Daniel Clark wrote:
> I made a simple test case that should make this bug (or my error in
> using the software) easy to reproduce. I'm attaching it since it is so
> tiny; it is also available from
> http://opensysadmin.com/bugs/runit/test1-service.tar.bz2
> 
> Below is a transcript of using it to demonstrate the problem:
> 
> root@cmlab:/tmp# tar xfj test1-service.tar.bz2
> root@cmlab:/tmp# cd test1-service/
> root@cmlab:/tmp/test1-service# ./runsvdir-here
> ^C
> root@cmlab:/tmp/test1-service# ps auxw | grep [s]v
> root     19882  0.0  0.0   2516   348 ?        Ss   22:28   0:00 runsv
> test1-service
> root     19883  0.0  0.0   2656   368 ?        S    22:28   0:00
> /usr/local/bin/svlogd -tt ./logs
> root     19884  0.0  0.0  10060  1408 ?        S    22:28   0:00
> /bin/sh ./test1-sv.sh
> root@cmlab:/tmp/test1-service# sv exit
> /tmp/test1-service/var-service/test1-service
> root@cmlab:/tmp/test1-service# sleep 7
> root@cmlab:/tmp/test1-service# ps auxw | grep [s]v
> root     19882  0.0  0.0   2516   348 ?        Ss   22:28   0:00 runsv
> test1-service
> root     19883  0.0  0.0   2656   368 ?        S    22:28   0:00
> /usr/local/bin/svlogd -tt ./logs
> root@cmlab:/tmp/test1-service# rm var-service/test1-service
> root@cmlab:/tmp/test1-service# sleep 7
> root@cmlab:/tmp/test1-service# ps auxw | grep [s]v
> root     19882  0.0  0.0   2516   348 ?        Ss   22:28   0:00 runsv
> test1-service
> root     19883  0.0  0.0   2656   368 ?        S    22:28   0:00
> /usr/local/bin/svlogd -tt ./logs
> 
> (I would think runsv and svlogd should not be showing up here, because
> runsvdir is no longer running, sv exit has been called, and the run
> director has been removed, with >5 second pauses between the removal
> and the ps)

When asked to exit, the runsv supervisor makes sure that all logs are
written to the log service before terminating; it first sends TERM to
the main service, then waits for it to terminate, and finally waits for
the log service to terminate, before runsv exits itself.

In the case of your example service, the main run script execs into a
shell script that starts a 'sleep' subprocess.  Now when runsv is told
to exit, it sends the service (the ./test1-sv.sh shell script) a TERM
signal, the shell script terminates (fine), but is leaving behind the
'sleep' subprocess.  The log service's run script execs into a svlogd
process, svlogd will terminate as soon as it sees end-of-file on the
pipe connected to its standard input.  Because there's still the 'sleep'
subprocess running with its output connected to the pipe, and so to
svlogd's standard input, svlogd will wait; it might well be that there's
still data available on the pipe to be written to the logs.  Once the
'sleep' subprocess exits, runsv should exit too.

HTH, Gerrit.


  parent reply	other threads:[~2007-02-23 14:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 20:14 Daniel Clark
2007-02-21 21:04 ` Daniel Clark
2007-02-23  3:51   ` Daniel Clark
2007-02-23 12:02     ` Laurent Bercot
2007-02-23 14:05     ` Gerrit Pape [this message]
2007-02-23 14:24       ` Alex Efros
2007-02-23 17:40         ` Daniel Clark
2007-02-23 17:32       ` Daniel Clark
2007-02-23 17:39         ` Paul Jarc
2007-02-23 17:46           ` Daniel Clark
2007-02-23 17:59             ` Paul Jarc
2007-02-23 18:25               ` Daniel Clark
2007-02-23 18:32                 ` Paul Jarc
2007-02-28 23:24                   ` Daniel Clark

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=20070223140504.17459.qmail@3f646761ee1f68.315fe32.mid.smarden.org \
    --to=pape@smarden.org \
    --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).