[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Daemontools



<assuming some haven't played with daemontools>
svscan starts supervise for each folder in /service, checking for sticky
bits (+t) on each folder as it goes. if there is a sticky bit it starts a
second (logging) service using the 'run' file in the 'log' folder, and
straps the two together with a pipe. daemons running under supervise -
qmail, tinydns, dnscache, and a bunch of others - usually log to STDOUT,
which makes its way to the logfile(s) via the pipe and multilog, which
adds a timestamp and deals with rotations (and is probably running via
setuidgid as a non priveleged user).

one could, as part of the init.d 'start' function, fire up supervise and
*then* use svc to control it (making sure to look out for multiple calls
to 'start'). however this will break logging, unless you checked for the
sticky bit and/or log directory and set up a pipe between the two.

so it sounds like svscan is going to be necessary. fine. we write an
init.d script something like the one attached to this email (which was a
quick fix that probably needs more work). svscan gets started at boot
(when? late? last?) and starts all the services in the service
directory. this is probably the 'preferred' way of doing it although it
raises issues with packages and dependencies.

djbdns works well - one uses [program]-conf to create a /etc/[program]
folder which contains configs for the program and run scripts (as well as
the aforementioned log dir). adding this service (even after startup) is
just a case of linking it into the 'service' folder and leaving it up to
svscan to kick things off a few seconds later.

i like daemontools (as do most people who have used it) and run it
everywhere. it would certainly be good if it could be included in a
package, provided that package was set up nicely, so it's good to see some
discussion about it. it'd be good to see something like chkconfig (or even
chkconfig itself) appearing too (although I'd say that's a discussion
that's been had before).

 - samj

On Tue, 30 Jan 2001, Adam McKenna wrote:

> On Tue, Jan 30, 2001 at 08:11:37PM -0500, Adam McKenna wrote:
> > the supervise log, you have to manually bring it up again.  That script
> > someone posted basically assumes that if you have a log directory, then you
> > want logging (although this may not always be the case)
> 
> I hate replying to myself, but actually the script should work as intended.
> If there is no supervise process, svc will not be able to bring up logging.
> svc only sends signals to supervise IIRC, and does not actually start up new
> supervise processes.
> 
> --Adam
> 
> 
#!/bin/bash
# chkconfig: 2345 80 20
# description: svscan starts multiple supervised services
# Sam Johnston (samj@faredge.com.au) 20010116

SERVICE_HOME=/var/service
PATH=/usr/local/bin:/usr/bin:/bin
export PATH

case "$1" in
  start)
    echo -n "Starting services: svscan"
    env - PATH="$PATH" svscan $SERVICE_HOME &
    echo $! > /var/run/svscan.pid
    echo "."
    ;;
  stop)
    echo -n "Stopping services: svscan"
    kill `cat /var/run/svscan.pid`
    for i in $SERVICE_HOME/*;
      do
        echo -n " `basename $i`";
        svc -dx $i;
	[ -d $i/log ] && svc -dx $i/log;
      done;
    echo "."    
    ;;
  stat)
    svstat $SERVICE_HOME/* $SERVICE_HOME/*/log
    ;;
  pause)
    echo "Pausing services: "
    for i in $SERVICE_HOME/*;
      do
        echo -n " `basename $i`";
        svc -p $i;
      done;
    echo "."
    ;;
  cont)
    echo "Continuing services: "
    for i in $SERVICE_HOME/*;
      do
        echo -n " `basename $i`";
        svc -c $i;
      done;
    echo "."
    ;;
  restart)
    $0 stop
    $0 start 
    ;;
  cdb)
    tcprules /var/qmail/etc/tcp.smtp.cdb /var/qmail/etc/tcp.smtp.tmp < /var/qmail/etc/tcp.smtp
    chmod 644 /var/qmail/etc/tcp.smtp*
    echo "Reloaded /var/qmail/etc/tcp.smtp."
    ;;
  help)
cat <<HELP
   stop -- stops services
  start -- starts services
  pause -- temporarily pauses services
   cont -- continues paused services
   stat -- displays status of services
restart -- stops and restarts services
HELP
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|stat|pause|cont|help}"
    exit 1
    ;;
esac

exit 0


Reply to: