summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runit/runsv.c27
-rw-r--r--runit/runsvdir.c27
-rw-r--r--runit/sv.c150
3 files changed, 204 insertions, 0 deletions
diff --git a/runit/runsv.c b/runit/runsv.c
index 813709d..cd80685 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -1,3 +1,30 @@
+/*
+Copyright (c) 2001-2006, Gerrit Pape
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
/* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */
/* TODO: depends on runit_lib.c - review and reduce/eliminate */
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 2d2b5db..2f54cfe 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -1,3 +1,30 @@
+/*
+Copyright (c) 2001-2006, Gerrit Pape
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
/* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */
/* TODO: depends on runit_lib.c - review and reduce/eliminate */
diff --git a/runit/sv.c b/runit/sv.c
index ac23a2d..051e64e 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -1,3 +1,153 @@
+/*
+Copyright (c) 2001-2006, Gerrit Pape
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* Taken from http://smarden.sunsite.dk/runit/sv.8.html:
+
+sv - control and manage services monitored by runsv
+
+sv [-v] [-w sec] command services
+/etc/init.d/service [-w sec] command
+
+The sv program reports the current status and controls the state of services
+monitored by the runsv(8) supervisor.
+
+services consists of one or more arguments, each argument naming a directory
+service used by runsv(8). If service doesn?t start with a dot or slash,
+it is searched in the default services directory /var/service/, otherwise
+relative to the current directory.
+
+command is one of up, down, status, once, pause, cont, hup, alarm, interrupt,
+1, 2, term, kill, or exit, or start, stop, restart, shutdown, force-stop,
+force-reload, force-restart, force-shutdown.
+
+The sv program can be sym-linked to /etc/init.d/ to provide an LSB init
+script interface. The service to be controlled then is specified by the
+base name of the "init script".
+
+status
+ Report the current status of the service, and the appendant log service
+ if available, to standard output.
+up
+ If the service is not running, start it. If the service stops, restart it.
+down
+ If the service is running, send it the TERM signal, and the CONT signal.
+ If ./run exits, start ./finish if it exists. After it stops, do not
+ restart service.
+once
+ If the service is not running, start it. Do not restart it if it stops.
+pause cont hup alarm interrupt quit 1 2 term kill
+ If the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT,
+ USR1, USR2, TERM, or KILL signal respectively.
+exit
+ If the service is running, send it the TERM signal, and the CONT signal.
+ Do not restart the service. If the service is down, and no log service
+ exists, runsv(8) exits. If the service is down and a log service exists,
+ send the TERM signal to the log service. If the log service is down,
+ runsv(8) exits. This command is ignored if it is given to an appendant
+ log service.
+
+sv actually looks only at the first character of above commands.
+
+status
+ Same as status.
+start
+ Same as up, but wait up to 7 seconds for the command to take effect.
+ Then report the status or timeout. If the script ./check exists in
+ the service directory, sv runs this script to check whether the service
+ is up and available; it's considered to be available if ./check exits
+ with 0.
+stop
+ Same as down, but wait up to 7 seconds for the service to become down.
+ Then report the status or timeout.
+restart
+ Send the commands term, cont, and up to the service, and wait up to
+ 7 seconds for the service to restart. Then report the status or timeout.
+ If the script ./check exists in the service directory, sv runs this script
+ to check whether the service is up and available again; it's considered
+ to be available if ./check exits with 0.
+shutdown
+ Same as exit, but wait up to 7 seconds for the runsv(8) process
+ to terminate. Then report the status or timeout.
+force-stop
+ Same as down, but wait up to 7 seconds for the service to become down.
+ Then report the status, and on timeout send the service the kill command.
+force-reload
+ Send the service the term and cont commands, and wait up to
+ 7 seconds for the service to restart. Then report the status,
+ and on timeout send the service the kill command.
+force-restart
+ Send the service the term, cont and up commands, and wait up to
+ 7 seconds for the service to restart. Then report the status, and
+ on timeout send the service the kill command. If the script ./check
+ exists in the service directory, sv runs this script to check whether
+ the service is up and available again; it?s considered to be available
+ if ./check exits with 0.
+force-shutdown
+ Same as exit, but wait up to 7 seconds for the runsv(8) process to
+ terminate. Then report the status, and on timeout send the service
+ the kill command.
+
+Additional Commands
+
+check
+ Check for the service to be in the state that's been requested. Wait up to
+ 7 seconds for the service to reach the requested state, then report
+ the status or timeout. If the requested state of the service is up,
+ and the script ./check exists in the service directory, sv runs
+ this script to check whether the service is up and running;
+ it's considered to be up if ./check exits with 0.
+
+Options
+
+-v
+ wait up to 7 seconds for the command to take effect.
+ Then report the status or timeout.
+-w sec
+ Override the default timeout of 7 seconds with sec seconds. Implies -v.
+
+Environment
+
+SVDIR
+ The environment variable $SVDIR overrides the default services directory
+ /var/service.
+SVWAIT
+ The environment variable $SVWAIT overrides the default 7 seconds to wait
+ for a command to take effect. It is overridden by the -w option.
+
+Exit Codes
+ sv exits 0, if the command was successfully sent to all services, and,
+ if it was told to wait, the command has taken effect to all services.
+
+ For each service that caused an error (e.g. the directory is not
+ controlled by a runsv(8) process, or sv timed out while waiting),
+ sv increases the exit code by one and exits non zero. The maximum
+ is 99. sv exits 100 on error.
+*/
+
/* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */
/* TODO: depends on runit_lib.c - review and reduce/eliminate */