supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Jameson Graef Rollins <jrollins@finestructure.net>
To: Mike Buland <xagafinelle@gmail.com>, supervision@list.skarnet.org
Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Subject: Re: Per-user service managers
Date: Thu, 20 Oct 2011 10:40:20 -0700	[thread overview]
Message-ID: <87aa8vblyz.fsf@servo.finestructure.net> (raw)
In-Reply-To: <CAK2oqq+65s_3oCTHGJkm7rOJqkgByGdZ3nWO7iG2jxF7K1xkNQ@mail.gmail.com>

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

On Thu, 20 Oct 2011 10:26:17 -0600, Mike Buland <xagafinelle@gmail.com> wrote:
> I wrote this little program that manages per-user runsv instances.
> For each user in the "svusers" group it starts a service manager in
> their ~/.sv directory.  The service manager runs as that user, so as
> long as they can run the sv program, they can manage their own
> services.
>
> Per-user service managers run independently of user logins.
>
> I've released this under the BSD license, and it's available on github.
>
> https://github.com/eichlan/usersv

Hey, Mike.  Very cool!  I actually wrote basically the exact same thing
a while ago, but never got around to publishing it.  I think this sort
of thing can be very useful.  Thanks for sharing.

I see that your system uses a single process that spawns a runsvdir for
each user.  The problem I see with that is that it's hard to
individually control the user runsvdir processes.  If you do have an
idea about how to control (ie. start/stop/restart/etc.) the user
runsvdir processes I would be interested in hearing it.

The system I put together uses a separate runsv dir for each user, and
the entire system is basically encapsulated in the runsv run script (and
log/run script), which I've pasted in below.  The env dir for this
particular example is as follows:

HOME=/home/jrollins
LOG=/home/jrollins/.service.log
PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
RUNSVDIR=/home/jrollins/.service
USER=jrollins

Anyway, just thought you might be interested, and thanks again for
sharing your work.

jamie.


servo 0$ cat /etc/sv/runsvdir-jrollins/run
#!/bin/sh
exec 2>&1
USER=`head env/USER`
RUNSVDIR=`head env/RUNSVDIR`
GROUPS=$(groups "$USER" | cut -d: -f2 | tr ' ' ':')
echo "${USER}${GROUPS}"
until [ -d "$RUNSVDIR" ] ; do
    sleep 10
done
if [ -d log/main ] ; then
    exec chpst -u "${USER}${GROUPS}" -e env \
	runsvdir -P "$RUNSVDIR"
else
    exec chpst -u "${USER}${GROUPS}" -e env \
	runsvdir -P "$RUNSVDIR" 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
fi

servo 0$ cat /etc/sv/runsvdir-jrollins/log/run
#!/bin/sh
set -e
LOG=`readlink -f ./main`
USER=`head ../env/USER`
if ! [ -d "$LOG" ] ; then
    mkdir -p -m0750 "$LOG"
    chown "$USER":"$USER" "$LOG"
fi
exec chpst -u "$USER" svlogd -tt "$LOG"

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

  reply	other threads:[~2011-10-20 17:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-20 16:26 Mike Buland
2011-10-20 17:40 ` Jameson Graef Rollins [this message]
2011-10-20 18:11   ` Mike Buland
2011-10-20 19:16     ` Jameson Graef Rollins
2011-10-20 19:21       ` Mike Buland
2011-10-21 16:44       ` problem with mailing list and multipart/mime? Jameson Graef Rollins
2011-10-21 18:55         ` Uffe Jakobsen
2011-10-22  1:31         ` Alex Efros
2011-10-22  2:01           ` Jameson Graef Rollins
2011-10-22 10:43             ` Alex Efros
2011-10-22 11:47               ` Laurent Bercot
2011-10-22 19:43                 ` Jameson Graef Rollins
2011-10-22 19:49                   ` Jameson Graef Rollins
2012-03-10 16:34                   ` Laurent Bercot
2011-10-22 19:16             ` Jameson Graef Rollins
2011-10-22  7:24         ` Laurent Bercot

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=87aa8vblyz.fsf@servo.finestructure.net \
    --to=jrollins@finestructure.net \
    --cc=dkg@fifthhorseman.net \
    --cc=supervision@list.skarnet.org \
    --cc=xagafinelle@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).