From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/1373 Path: news.gmane.org!not-for-mail From: "Daniel Clark" Newsgroups: gmane.comp.sysutils.supervision.general Subject: How to kill runsv, no matter what? Date: Wed, 21 Feb 2007 15:14:19 -0500 Message-ID: <5422d5e60702211214q7ecaf23co838e9ff1b9be32de@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1172088878 4851 80.91.229.12 (21 Feb 2007 20:14:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Feb 2007 20:14:38 +0000 (UTC) To: supervision@list.skarnet.org Original-X-From: supervision-return-1609-gcsg-supervision=m.gmane.org@list.skarnet.org Wed Feb 21 21:14:29 2007 Return-path: Envelope-to: gcsg-supervision@gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by lo.gmane.org with smtp (Exim 4.50) id 1HJxr5-0005iX-4X for gcsg-supervision@gmane.org; Wed, 21 Feb 2007 21:14:23 +0100 Original-Received: (qmail 32650 invoked by uid 76); 21 Feb 2007 20:14:43 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 32642 invoked from network); 21 Feb 2007 20:14:42 -0000 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=ctjr/St7nxgmER/95fBKOujKGqjoMZQO3t2xInAT7Ys8IpgzzH/xI72Qwx6pgwdIPEfhmFu8x+Kx5WmF1LzO34ry32VdhkSXOci5R9u5rQMeiK6fmGfx3MuqtZt7bB4aDcQbn4Sp4qamHvBy2RHlObIoQh5Mk5hNtZDYJ3t8BoA= Original-Sender: djbclark@gmail.com Content-Disposition: inline X-Google-Sender-Auth: ac731573960d7f13 Xref: news.gmane.org gmane.comp.sysutils.supervision.general:1373 Archived-At: I'm integrating runit support into bcfg2 [1], both as something bcfg2 can control, and as an encap [2] package [3]. I'm replacing daemontools, as djb's annoying redistribution policies wouldn't allow me to distribute Xen images or LiveCDs (as I patched daemontools since there hasn't been a release in a very long time, but there have been bugs). I'm trying to get to a state where I can add and remove the runit package without leaving any state behind (I'm using it for runsvdir, not as an init replacement). When the package is removed, all of the runit services should stop, and state about what services were started is saved somewhere; on reinstall, that state should be reintroduced, and any runit services should be restarted. In theory this should be pretty trivial (assuming I am RTFMing correctly); I think something like this in the removal stage: test -d /usr/local/var/service/.disabled || mkdir /usr/local/var/service/.disabled mv /usr/local/var/service/* /usr/local/var/service/.disabled/ 2>/dev/null \ || printf "No services to disable.\n" printf "Waiting 7 seconds for runsv processes to die...\n" sleep 7 # ... (Code that stops runsvdir) ... for service in `ls /usr/local/etc/sv`; do test -d /usr/local/etc/sv/$service/supervise \ && rm -rf /usr/local/etc/sv/$service/supervise test -d /usr/local/etc/sv/$service/log/supervise \ && rm -rf /usr/local/etc/sv/$service/log/supervise done However in practice there are some services that continue to have a "runsv" process even after I remove them from the directory "runsvdir" is monitoring and wait >5 seconds. Below is an example of such a service that refuses to die. With daemontools I had a script called svrm that did this (below), but the same idiom doesn't seem to work with runit/runsvdir. Am I doing something wrong, or is this a bug? ---------------------------------------------------------------------- root@pawn:/usr/local/etc/sv# cat bcfg2-client/run #!/bin/sh exec 2>&1 printf "*** exec /usr/local/bin/chpst -e /usr/local/etc/default/bcfg2-client/env ./bcfg2-client.sh ...\n" exec /usr/local/bin/chpst -e /usr/local/etc/default/bcfg2-client/env ./bcfg2-client.sh ---------------------------------------------------------------------- root@pawn:/usr/local/etc/sv# cat bcfg2-client/bcfg2-client.sh #!/bin/sh # note: variables provided from environment with chpst -e: # /usr/local/etc/default/bcfg2-client/env/OPTIONS # /usr/local/etc/default/bcfg2-client/env/RUN_INTERVAL_SECONDS ENVDIR="/usr/local/etc/default/bcfg2-client/env" # make sure we have options if [ ! -f ${ENVDIR}/OPTIONS ]; then printf "WARNING: ${ENVDIR}/OPTIONS\n" printf "WARNING: does not exist. Using default of \"-q -v -d -n\"\n" OPTIONS="-q -v -d -n" fi # make sure we have a sleep variable if [ "${RUN_INTERVAL_SECONDS}x" = "x" ]; then printf "WARNING: ${ENVDIR}/RUN_INTERVAL_SECONDS\n" printf "WARNING: does not exist or has no value.\n" printf "WARNING: Using default of 3600 seconds between runs.\n" RUN_INTERVAL_SECONDS=3600 fi # loop forever while : do printf "*** starting /usr/local/bin/bcfg2 ${OPTIONS} ...\n" /usr/local/bin/bcfg2 ${OPTIONS} printf "*** sleeping ${RUN_INTERVAL_SECONDS} seconds ...\n" sleep ${RUN_INTERVAL_SECONDS} done exit 0 ---------------------------------------------------------------------- ---------------------------------------------------------------------- [1] http://www.bcfg2.org [2] http://www.encap.org [3] http://www.bcfg2.org/browser/trunk/bcfg2/encap/src/encap-profiles/runit-1.7.2.ep Thanks for any help, -- Daniel Clark # http://dclark.us # http://opensysadmin.com