diff options
author | Gerrit Pape <pape@smarden.org> | 2004-09-21 18:08:37 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2004-09-21 18:08:37 +0000 |
commit | b23a59b512c26497755ab68ba9fd464cf574a5f3 (patch) | |
tree | 200eef2a79040b98696fd01750add52a616eaacc | |
parent | f0f2b280c58a5ce85c9e3cb3a581ca6b0bc70105 (diff) | |
download | runit-b23a59b512c26497755ab68ba9fd464cf574a5f3.tar.gz runit-b23a59b512c26497755ab68ba9fd464cf574a5f3.tar.xz runit-b23a59b512c26497755ab68ba9fd464cf574a5f3.zip |
* runsvdir.c: new option -P, run each runsv process in a new session and
process group (thx Charlie Brady). * man/runsvdir.8: adapt; typo.
-rw-r--r-- | doc/runsvdir.8.html | 71 | ||||
-rw-r--r-- | man/runsvdir.8 | 24 | ||||
-rw-r--r-- | package/CHANGES | 7 | ||||
-rw-r--r-- | src/runsvdir.c | 11 |
4 files changed, 69 insertions, 44 deletions
diff --git a/doc/runsvdir.8.html b/doc/runsvdir.8.html index 691ccac..e37f508 100644 --- a/doc/runsvdir.8.html +++ b/doc/runsvdir.8.html @@ -12,42 +12,50 @@ runsvdir - starts and monitors a collection of <i>runsv(8)</i> processes <h2><a name='sect1'>Synopsis</a></h2> <b>runsvdir</b> -<i>dir</i> [ <i>log</i> ] +[-P] <i>dir</i> [ <i>log</i> ] <h2><a name='sect2'>Description</a></h2> -<i>dir</i> must be a directory. <i>log</i> is a space holder for -a readproctitle log, and must be at least seven characters long or absent. +<i>dir</i> must be a directory. <i>log</i> is a space holder +for a readproctitle log, and must be at least seven characters long or +absent. <p> +<b>runsvdir</b> starts a <i><b>runsv</b>(8)</i> process for each subdirectory in the +services directory <i>dir</i>, up to a limit of 1000 subdirectories. <b>runsvdir</b> skips +subdirectory names starting with dots. <i><b>runsv</b>(8)</i> must be in <b>runsvdir</b>’s PATH. <p> -<b>runsvdir</b> starts a <i><b>runsv</b>(8)</i> process for each subdirectory in the services -directory <i>dir</i>, up to a limit of 1000 subdirectories. <b>runsvdir</b> skips subdirectory -names starting with dots. <i><b>runsv</b>(8)</i> must be in <b>runsvdir</b>’s PATH. <p> -At least every -five seconds, <b>runsvdir</b> checks if <i>dir</i> has changed. If it sees a new subdirectory -in services directory <i>dir</i>, it starts a new <i><b>runsv</b>(8)</i> process. If it sees -an old sudirectory where a <i><b>runsv</b>(8)</i> process has exited, it restarts the -<i><b>runsv</b>(8)</i> process. If <b>runsvdir</b> sees a subdirectory being removed that was -previously there, it sends the corresponding <i><b>runsv</b>(8)</i> process a TERM signal, -stops monitoring this process, and so does not restart the <i><b>runsv</b>(8)</i> process -if it exits. <p> -If the <i>log</i> argument is given to <b>runsvdir</b>, all output to standard -error is redirected to this <i>log</i>, which is similar to the <i><b>readproctitle</b>(8)</i> -log. To see the most recent error messages, use a process-listing tool such -as <i><b>ps</b>(1)</i>. <b>runsvdir</b> writes a dot to the readproctitle log every 15 minutes -so that old error messages expire. <p> -Normally <b>runsvdir</b> is started by <i><b>runit</b>(8)</i> -in stage 2. -<h2><a name='sect3'>Signals</a></h2> +At least every five seconds <b>runsvdir</b> checks whether the services directory +<i>dir</i> has changed. If it sees a new subdirectory in <i>dir</i>, it starts a new <i><b>runsv</b>(8)</i> +process. If it sees an old sudirectory where a <i><b>runsv</b>(8)</i> process has exited, +it restarts the <i><b>runsv</b>(8)</i> process. If <b>runsvdir</b> sees a subdirectory being +removed that was previously there, it sends the corresponding <i><b>runsv</b>(8)</i> +process a TERM signal, stops monitoring this process, and so does not restart +the <i><b>runsv</b>(8)</i> process if it exits. <p> +If the <i>log</i> argument is given to <b>runsvdir</b>, +all output to standard error is redirected to this <i>log</i>, which is similar +to the <i><b>readproctitle</b>(8)</i> log. To see the most recent error messages, use +a process-listing tool such as <i><b>ps</b>(1)</i>. <b>runsvdir</b> writes a dot to the readproctitle +log every 15 minutes so that old error messages expire. +<h2><a name='sect3'>Options</a></h2> + +<dl> + +<dt><b>-P</b> </dt> +<dd>use <i><b>setsid</b>(2)</i> +to run each <i><b>runsv</b>(8)</i> process in a new session and separate process group. +</dd> +</dl> + +<h2><a name='sect4'>Signals</a></h2> If <b>runsvdir</b> receives a TERM signal, it exits with 0 immediately. <p> If <b>runsvdir</b> receives a HUP signal, it sends a TERM signal to each <i><b>runsv</b>(8)</i> process it is monitoring and then exits with 111. -<h2><a name='sect4'>See Also</a></h2> +<h2><a name='sect5'>See Also</a></h2> <i>runsv(8)</i>, <i>runit(8)</i>, <i>runit-init(8)</i>, <i>runsvchdir(8)</i>, <i>runsvctrl(8)</i>, <i>runsvstat(8)</i>, <i>chpst(8)</i>, <i>svlogd(8)</i>, -<i>utmpset(8)</i>, <i>svwaitdown(8)</i>, <i>svwaitup(8)</i> <p> -<i>http://smarden.org/runit/</i> -<h2><a name='sect5'>Author</a></h2> -Gerrit -Pape <pape@smarden.org> <p> +<i>utmpset(8)</i>, <i>svwaitdown(8)</i>, <i>svwaitup(8)</i>, <i>setsid(2)</i> <p> +<i>http://smarden.org/runit/</i> + +<h2><a name='sect6'>Author</a></h2> +Gerrit Pape <pape@smarden.org> <p> <hr><p> <a name='toc'><b>Table of Contents</b></a><p> @@ -55,9 +63,10 @@ Pape <pape@smarden.org> <p> <li><a name='toc0' href='#sect0'>Name</a></li> <li><a name='toc1' href='#sect1'>Synopsis</a></li> <li><a name='toc2' href='#sect2'>Description</a></li> -<li><a name='toc3' href='#sect3'>Signals</a></li> -<li><a name='toc4' href='#sect4'>See Also</a></li> -<li><a name='toc5' href='#sect5'>Author</a></li> +<li><a name='toc3' href='#sect3'>Options</a></li> +<li><a name='toc4' href='#sect4'>Signals</a></li> +<li><a name='toc5' href='#sect5'>See Also</a></li> +<li><a name='toc6' href='#sect6'>Author</a></li> </ul> </body> </html> diff --git a/man/runsvdir.8 b/man/runsvdir.8 index 685b450..1a63e81 100644 --- a/man/runsvdir.8 +++ b/man/runsvdir.8 @@ -3,6 +3,7 @@ runsvdir \- starts and monitors a collection of runsv(8) processes .SH SYNOPSIS .B runsvdir +[\-P] .I dir [ .I log @@ -27,12 +28,12 @@ must be in .BR runsvdir 's PATH. .P -At least every five seconds, +At least every five seconds .B runsvdir -checks if +checks whether the services directory .I dir has changed. -If it sees a new subdirectory in services directory +If it sees a new subdirectory in .IR dir , it starts a new .BR runsv (8) @@ -66,12 +67,14 @@ To see the most recent error messages, use a process-listing tool such as .B runsvdir writes a dot to the readproctitle log every 15 minutes so that old error messages expire. -.P -Normally -.B runsvdir -is started by -.BR runit (8) -in stage 2. +.SH OPTIONS +.TP +.B \-P +use +.BR setsid (2) +to run each +.BR runsv (8) +process in a new session and separate process group. .SH SIGNALS If .B runsvdir @@ -93,7 +96,8 @@ chpst(8), svlogd(8), utmpset(8), svwaitdown(8), -svwaitup(8) +svwaitup(8), +setsid(2) .P http://smarden.org/runit/ .SH AUTHOR diff --git a/package/CHANGES b/package/CHANGES index 3befff8..f72a2e1 100644 --- a/package/CHANGES +++ b/package/CHANGES @@ -1,15 +1,18 @@ runit 1.0.5 Mon, 20 Sep 2004 20:12:14 +0000 * svlogd.c: fix line buffer handling for pattern matching (thx Enrico - Scholz); minor bug fixes. + Scholz); properly retry writing to current on error; minor. * doc/index.html: wording; add link to useinit.html; remove link to runit - on LinuxFromScratch. + on linuxfromscratch. * doc/runscripts.html: add hint, some getties need to be run in a new session/process group (thx Dan Melomedman). * man/svlogd.8: minor fixes. * man/svwaitdown.8: remove hint about -x option. * package/check, package/compile, package/install, package/install-man, package/upgrade: use set -e instead of #!/bin/sh -e. + * runsvdir.c: new option -P, run each runsv process in a new session and + process group (thx Charlie Brady). + * man/runsvdir.8: adapt; typo. runit 1.0.4 Sun, 01 Aug 2004 18:29:36 +0000 diff --git a/src/runsvdir.c b/src/runsvdir.c index 2faa3df..27aef7f 100644 --- a/src/runsvdir.c +++ b/src/runsvdir.c @@ -16,7 +16,7 @@ #include "sig.h" #include "ndelay.h" -#define USAGE " dir" +#define USAGE " [-P] dir" #define VERSION "$Id$" #define MAXSERVICES 1000 @@ -39,6 +39,7 @@ int logpipe[2]; iopause_fd io[1]; struct taia stamplog; int exitsoon =0; +int pgrp =0; void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } void fatal(char *m1, char *m2) { @@ -72,6 +73,7 @@ void runsv(int no, char *name) { warn("unable to set filedescriptor for log service", 0); sig_uncatch(sig_hangup); sig_uncatch(sig_term); + if (pgrp) setsid(); pathexec_run(*prog, prog, (const char* const*)environ); fatal("unable to start runsv ", name); } @@ -174,6 +176,13 @@ int main(int argc, char **argv) { progname =*argv++; if (! argv || ! *argv) usage(); + if (**argv == '-') { + switch (*(*argv +1)) { + case 'P': pgrp =1; + case '-': ++argv; + } + if (! argv || ! *argv) usage(); + } sig_catch(sig_term, s_term); sig_catch(sig_hangup, s_hangup); |