Bypassing svscan
Daniel Exbrayat
daniel.exbrayat at tele2.fr
Sat May 19 14:14:34 BST 2007
I have tested the following. It is intended to bypass "svscan" and "supervise" daemons.
You have to note that "multilog" is not started as a service as it should be.
It is not a "production" solution, more something to understand how put stuff together.
in /var/djbdns/dnscache/ directory, I have added a "multilog" fifo:
# mkfifo multilog
# chown dnscache.daemon multilog
# ll multilog
prw-r--r-- 1 dnscache daemon 0 2007-05-19 14:39 multilog
#=====================================================================
then I force dnscache writing stdout to "multilog" fifo:
# cat /var/djbdns/dnscache/experimental_run
#!/bin/bash
#
cd `dirname $0`
exec >multilog
exec 2>&1
exec <seed
exec -c envdir ./env sh -c '
exec envuidgid dnscache /usr/local/bin/softlimit -o250 -d "$DATALIMIT" /usr/local/bin/dnscache
'
#=====================================================================
then I force multilog reading stdin from "multilog" fifo:
# cat /var/djbdns/dnscache/log/experimental_run
#!/bin/sh
#
cd `dirname $0`
exec <../multilog
exec setuidgid multilog /usr/local/bin/multilog t n20 '-* sent *' '-* rr *' /var/log/dnscache
#=====================================================================
# cat /etc/event.d/dnscache
# dnscache
#
# This service starts dnscache DJBDNS service
#
description "service dnscache daemon (part of DJBDNS tools)"
start on runlevel 2
stop on shutdown
pre-start script
/var/djbdns/dnscache/log/experimental_run &
end script
exec /var/djbdns/dnscache/experimental_run
#=====================================================================
# ps ax
7024 ? S 0:00 /usr/local/bin/multilog t n20 -* sent * -* rr * /var/log/dnscache
7026 ? Ss 0:00 /usr/local/bin/dnscache
...
# ll /proc/7024/fd/
total 0
lr-x------ 1 multilog daemon 64 2007-05-19 15:08 0 -> /var/djbdns/dnscache/multilog
...
# ll /proc/7026/fd/
total 0
l-wx------ 1 root root 64 2007-05-19 15:09 1 -> /var/djbdns/dnscache/multilog
l-wx------ 1 root root 64 2007-05-19 15:09 2 -> /var/djbdns/dnscache/multilog
...
> ----- Original Message -----
> From: "Daniel L. Miller" <dmiller at amfes.com>
> To: <upstart-devel at lists.ubuntu.com>
> Sent: Friday, May 18, 2007 1:11 AM
> Subject: Re: Bypassing svscan
>
>
> > Scott James Remnant wrote:
> > > On Thu, 2007-05-17 at 21:43 +0200, Daniel Exbrayat wrote:
> > >
> > >
> > >> # svscan
> > >> #
> > >> # This service starts svscan DJBDNS utility which in turn starts the
> > >> # DJBDNS services belonging to /etc/svscan
> > >> #
> > >> description "service svscan daemon (part of DJBDNS tools)"
> > >>
> > >> start on network_is_up
> > >> stop on shutdown
> > >>
> > >> pre-start script
> > >> PATH="/usr/local/bin"
> > >> end script
> > >>
> > >>
> > > This PATH won't affect anything, since the shell it is set in is lost at
> > > the end of the script. You may have better luck with the following line
> > > in the config file:
> > >
> > > env PATH=/usr/local/bin
> > >
> > >
> > >> # by the way, I am wondering how to show status for each "DJBDNS"
> > >> # services. Something like:
> > >>
> > >>
> > > Is it possible to manually start each service? If so, you could use
> > > instances to do this.
> > >
> > > Scott
> > >
> > I posted something on this earlier. I run the "services" directly,
> > without supervise or svscan - because after all, svscan was also
> > intended as an inittab replacement, and if we're using upstart it seems
> > silly to continue trying to use multiple "master" daemons. An example
> > for starting dnscache:
> >
> > # dnscache
> > #
> > # This task runs the dnscache server.
> >
> > start on runlevel-1
> > start on runlevel-2
> > start on runlevel-3
> > start on runlevel-4
> > start on runlevel-5
> > start on runlevel-6
> >
> > stop on shutdown
> >
> > exec envdir /var/lib/dnscache/env envuidgid dnscache \
> > softlimit -o250 -d "$DATALIMIT" /usr/bin/dnscache
> > respawn
> >
> > ## EOF
> >
> >
> >
> > This works just dandy for executing dnscache. The downside is I don't
> know how to perform the logging. The manpage for djb's "supervise" says it
> creates a pipe between the primary service and the logger (typically the
> "multilog" program for djb stuff). I've tried building a script that
> includes logging:
> >
> > # dnscache
> > #
> > # This task runs the dnscache server.
> >
> > start on runlevel-1
> > start on runlevel-2
> > start on runlevel-3
> > start on runlevel-4
> > start on runlevel-5
> > start on runlevel-6
> >
> > stop on shutdown
> >
> > script
> > exec 2>&1
> > exec envdir /var/lib/dnscache/env \
> > envuidgid dnscache softlimit -o250 -d "$DATALIMIT" \
> > /usr/bin/dnscache | \
> > setuidgid dnslog multilog t /var/log/djbdns/dnscache
> > end script
> > respawn
> >
> > ## EOF
> >
> >
> > And while dnscache runs, and multilog starts - it seems the pipe never
> > gets created because multilog simply opens the logfile without writing
> > anything. Output of "ps ax | grep 'dns'":
> >
> > 13593 ? Ss 0:00 /bin/sh -e -c exec 2>&1?exec envdir
> > /var/lib/dnscache/env envuidgid dnscache softlimit -o250 -d "$DATALIMIT"
> > /usr/bin/dnscache | setuidgid dnslog multilog t
> > /var/log/djbdns/dnscache? /bin/sh
> > 13594 ? S 0:00 /usr/bin/dnscache
> > 13595 ? S 0:00 multilog t /var/log/djbdns/dnscache
> >
> >
> > Since I have no shell knowledge, I'm probably missing something basic in
> my "exec" line. Any ideas?
> >
> > --
> > Daniel
> >
> >
> > --
> > upstart-devel mailing list
> > upstart-devel at lists.ubuntu.com
> > Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/upstart-devel
>
More information about the upstart-devel
mailing list