supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* sv exit doesn't seem to work properly
@ 2006-10-01 20:19 Vincent Danen
  2006-10-02  2:05 ` Alex Efros
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Danen @ 2006-10-01 20:19 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]

Using runit 1.6.0, it doesn't look like "sv exit" is working as it
should.  I'm working to replace some scripts which use svwaitdown in
/etc/runit/3 with using sv, and was trying to use "sv exit [service]"
but when I do, the service goes down, runsv is killed, but then within a
few seconds it's starting again.  It's almost like it's not properly
writing the new state for runsvdir to know we want it down.

If I use "sv down [service]" the service goes down properly.  It's not
that big of a deal to use sv down in stage 3 I guess, but it's not
what's illustrated in the sample debian script (which uses
force-stop then exit).  I figure using exit alone would be
sufficient (force-stop shuts the service down but then it comes
right back up when I use exit).

Am I doing something wrong?

My stage 3 script looks like this:

[vdanen@build trunk]$ cat 3
#!/bin/execlineb

/bin/fdmove -c 2 1

/bin/export PATH "/sbin:/bin:/usr/sbin:/usr/bin"

/sbin/chpst -e /etc/sysconfig/env/runit/

/bin/import -D 180 STAGE_3_TIMEOUT
/bin/import -D 14 GETTY_TIMEOUT

/bin/elglob -0 GETTYS /service/mingetty-*
/bin/elglob -0 ALLSERVICES /service/*

/bin/foreground { /bin/echo "Waiting up to ${GETTY_TIMEOUT} seconds for getties to stop..." }
/bin/foreground { /sbin/sv -w $GETTY_TIMEOUT force-stop $GETTYS }
/bin/foreground { /sbin/sv exit $GETTYS }

/bin/foreground { /bin/echo "Waiting up to ${STAGE_3_TIMEOUT} seconds for services to stop..." }
/bin/foreground { /sbin/sv -w $STAGE_3_TIMEOUT force-stop $ALLSERVICES }
/bin/foreground { /sbin/sv exit $ALLSERVICES }

/bin/foreground { /bin/echo "Executing shutdown..." }

/sbin/rc 0


It's pretty much the same as the debian script with a few additions and
it's written in execline rather than bash.

Any ideas?  Right now I'm thinking just to use force-stop and get rid of
the exit call altogether and let /sbin/rc handle sending all the runsv
services the TERM signal when shutting the system down.

-- 
{FEE30AD4 : 7F6C A60C 06C2 4811 FA1C  A2BC 2EBC 5E32 FEE3 0AD4}
mysql> SELECT * FROM users WHERE clue > 0;
Empty set (0.00sec)

[-- Attachment #2: Type: application/pgp-signature, Size: 186 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: sv exit doesn't seem to work properly
  2006-10-01 20:19 sv exit doesn't seem to work properly Vincent Danen
@ 2006-10-02  2:05 ` Alex Efros
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Efros @ 2006-10-02  2:05 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]

Hi!

On Sun, Oct 01, 2006 at 02:19:36PM -0600, Vincent Danen wrote:
> Am I doing something wrong?

Yep. sv work correctly. But you must kill runsvdir first. If you 'exit'
runsv without killing runsvdir, then runsvdir will restart runsv, then
runsv will restart service which isn't what you want in /etc/runit/3. ;-)

> My stage 3 script looks like this:

My stage 3 script start with some fd redirection and log initialization,
then:

# 1) Send TERM to (all - some users on my servers also run it) runsvdir
#    to force it exit immediately.
# 2) Send TERM to all runsv (same as `sv exit`).
# 3) Send TERM to all services (so services will receive 2 TERM signals -
#    one from their runsv and one from this command, but this is harmless).
# 4) Send TERM to all other processes, not monitored by runsv.
killall5 -15
# 1) Gracefully wait up to 7 seconds until all services will be down before
#    continue shutdown process.
# 2) I'm not sure, but may also send KILL to hang services - not sure
#    because runsv already asked to 'exit' by previous command.
sv force-stop /var/service/* &>/dev/null

and after these commands shutdown continues: saving sound mixer state,
down network interfaces, adding reboot record to wtmp, killall5 -9 (just
for the case), and unmount everything.

-- 
			WBR, Alex.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-02  2:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-01 20:19 sv exit doesn't seem to work properly Vincent Danen
2006-10-02  2:05 ` Alex Efros

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).