supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Dean Hall <deanpence@gmail.com>
Subject: Re: Adding a 'setup' phase to service startup?
Date: Wed, 23 Feb 2005 23:40:54 -0500	[thread overview]
Message-ID: <421D5AD6.9000107@gmail.com> (raw)
In-Reply-To: <slrnd1poqa.cev.lars@flowers.house.oddbit.com>

Lars Kellogg-Stedman wrote:
>>Although I think runit itself should remain pristine in that it only
>>runs the ./run script for a service...

I almost forgot. Here's a sample implementation that I'm currently using
for dnscache. This is only one method of using sv-tools, but I think
it's an elegant one. Also, I think it's one that leaves the most room
open for elegant automation and even (for those who like them) GUI tools.

(Please keep in mind that I'm running on gentoo, which is very
FHS-compliant; some day I'll break out of the FHS shell (again).)


# This envdir sets the environment for sv-run. It tells sv-run not to
check dependencies and gives it an envdir to fetch before calling
./run-service.
--------
`envdir-print /etc/envdir.d/dnscache/meta`:
--------
SV_NO_DEPS='1'
SV_RUN_ENVDIR='/etc/envdir.d/dnscache/prerun'
--------

# This envdir sets the environment for ./run-service.
--------
`envdir-print /etc/envdir.d/dnscache/prerun`:
--------
ENVDIR='/etc/envdir.d/dnscache/service'
SEED='/var/lib/dnscache-seed'
USER='dnscache'
--------

# This envdir sets the environment for dnscache itself.
--------
`envdir-print /etc/envdir.d/dnscache/service`:
--------
CACHESIZE='10000000'
DATALIMIT='30000000'
IP='192.168.0.53'
IPSEND='0.0.0.0'
ROOT='/etc/service.d/all/dnscache/root'
--------

# Obviously, this gets run first:
--------
./run:
--------
#!/bin/sh
#
PATH='/usr/sbin:/usr/bin:/sbin:/bin'

exec 2>&1
exec \
        envdir /etc/envdir.d/dnscache/meta \
        sv-run
--------

# After checking dependencies and such, sv-run runs this:
--------
./run-service:
--------
#!/bin/sh
#
# Requires:
# - USER
# - SEED
#
PATH='/usr/sbin:/usr/bin:/sbin:/bin'

# Create a new random seed.
dd if=/dev/urandom of="$SEED" count=1 bs=128 > /dev/null 2>&1

exec 2>&1
exec < "$SEED"
exec \
        env - PATH="$PATH" \
        envuidgid "$USER" \
        envdir "$ENVDIR" \
        dnscache
--------


d


  parent reply	other threads:[~2005-02-24  4:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-21 17:41 Lars Kellogg-Stedman
2005-02-22  4:08 ` Dean Hall
2005-02-22 15:06   ` Thomas Schwinge
2005-02-23 20:07   ` Lars Kellogg-Stedman
2005-02-24  4:28     ` Dean Hall
2005-02-24  4:40     ` Dean Hall [this message]
2005-02-23 21:12 ` Stefan Karrmann
2005-03-07 11:56 ` Gerrit Pape

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=421D5AD6.9000107@gmail.com \
    --to=deanpence@gmail.com \
    /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).