From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2113 Path: news.gmane.org!not-for-mail From: Jameson Graef Rollins Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: Per-user service managers Date: Thu, 20 Oct 2011 10:40:20 -0700 Message-ID: <87aa8vblyz.fsf@servo.finestructure.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1319132439 1100 80.91.229.12 (20 Oct 2011 17:40:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2011 17:40:39 +0000 (UTC) Cc: Daniel Kahn Gillmor To: Mike Buland , supervision@list.skarnet.org Original-X-From: supervision-return-2347-gcsg-supervision=m.gmane.org@list.skarnet.org Thu Oct 20 19:40:35 2011 Return-path: Envelope-to: gcsg-supervision@lo.gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1RGwbb-0003b1-1i for gcsg-supervision@lo.gmane.org; Thu, 20 Oct 2011 19:40:35 +0200 Original-Received: (qmail 13823 invoked by uid 76); 20 Oct 2011 17:43:37 -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 13815 invoked from network); 20 Oct 2011 17:43:37 -0000 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new In-Reply-To: User-Agent: Notmuch/0.9-15-g937a514 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2113 Archived-At: On Thu, 20 Oct 2011 10:26:17 -0600, Mike Buland 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" --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJOoF0FAAoJEO00zqvie6q8EP8QAJ2dodQxSWrIc5ZYWg2uGMjN 4kOYMKDK/YmXoyKmyjSXdq/1q3JDteqzw7chfx40+YA4or+Rw/XacV0i0iVBNvCy U1U63cLTuPLQPPgExdUTDEsZBOhCrM/HznN0ov49WLkhGYuwOScOk2WQOghusHCF vLvCuf0pjLzEll+ZRyBaMg1CtNbb07pWZtCH5CrAh90SW+1hecwn7ZWLdzo54FGW IqG3fEGO/xkG3Lyj23kgQqtwQbTC7gWLT7h2N7SG8Zea3eDlkYLM7e0mWFDFiBbe fFdC/Aa9zg8SRk0FB/W7NCIWwLT1JyV3g1YGnbrEVUlXga8VA005gl28fztwzbUZ c4/gOaTNHE9F7cyRxuHhK628k0VyAxzej93ioUEKqAdQwr72B41PtKKovJ7l94Xu cod4rzlunnhxqO/SCVGHTPuFaweJONjP8RbwdPORhhaHYW8QgbgAj6AXKTMTO+o8 hl2vwopDkNZu1afbAAIxi+GocBo80qD0yUaNE52R9k0h4PjfPBcFUa4+aksSC4e5 GA/44+957xwDSox4HaOyFmhjdPelHN9fcnXrSSjIK9L05C05f4AEnHQiLh6+UaBq t1pet85OCvg0BNwU+pmiCSV5xdqyJMT2j8PhMov8H11i3Y5FBxtKm4/hrpIerN6i +ULCN8E+tzk9IvDZRE/x =/kpN -----END PGP SIGNATURE----- --=-=-=--