diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-12 23:34:52 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-12 23:34:52 +0000 |
| commit | 8a164052bfcf391368e267dae792a56b80174eba (patch) | |
| tree | 593cbbb387befb50ad2a61fc01d026a97ad16b63 | |
| parent | d55a36255d003c7093de67b615607f1ebb850838 (diff) | |
| download | busybox-w32-8a164052bfcf391368e267dae792a56b80174eba.tar.gz busybox-w32-8a164052bfcf391368e267dae792a56b80174eba.tar.bz2 busybox-w32-8a164052bfcf391368e267dae792a56b80174eba.zip | |
add missing copyright statements and doc for sv
| -rw-r--r-- | runit/runsv.c | 27 | ||||
| -rw-r--r-- | runit/runsvdir.c | 27 | ||||
| -rw-r--r-- | runit/sv.c | 150 |
3 files changed, 204 insertions, 0 deletions
diff --git a/runit/runsv.c b/runit/runsv.c index 813709d41..cd806851e 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2001-2006, Gerrit Pape | ||
| 3 | All rights reserved. | ||
| 4 | |||
| 5 | Redistribution and use in source and binary forms, with or without | ||
| 6 | modification, are permitted provided that the following conditions are met: | ||
| 7 | |||
| 8 | 1. Redistributions of source code must retain the above copyright notice, | ||
| 9 | this list of conditions and the following disclaimer. | ||
| 10 | 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | notice, this list of conditions and the following disclaimer in the | ||
| 12 | documentation and/or other materials provided with the distribution. | ||
| 13 | 3. The name of the author may not be used to endorse or promote products | ||
| 14 | derived from this software without specific prior written permission. | ||
| 15 | |||
| 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 19 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
| 22 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 23 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 24 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 26 | */ | ||
| 27 | |||
| 1 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ | 28 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ |
| 2 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ | 29 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ |
| 3 | 30 | ||
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index 2d2b5db31..2f54cfef8 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2001-2006, Gerrit Pape | ||
| 3 | All rights reserved. | ||
| 4 | |||
| 5 | Redistribution and use in source and binary forms, with or without | ||
| 6 | modification, are permitted provided that the following conditions are met: | ||
| 7 | |||
| 8 | 1. Redistributions of source code must retain the above copyright notice, | ||
| 9 | this list of conditions and the following disclaimer. | ||
| 10 | 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | notice, this list of conditions and the following disclaimer in the | ||
| 12 | documentation and/or other materials provided with the distribution. | ||
| 13 | 3. The name of the author may not be used to endorse or promote products | ||
| 14 | derived from this software without specific prior written permission. | ||
| 15 | |||
| 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 19 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
| 22 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 23 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 24 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 26 | */ | ||
| 27 | |||
| 1 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ | 28 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ |
| 2 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ | 29 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ |
| 3 | 30 | ||
diff --git a/runit/sv.c b/runit/sv.c index ac23a2da3..051e64e67 100644 --- a/runit/sv.c +++ b/runit/sv.c | |||
| @@ -1,3 +1,153 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2001-2006, Gerrit Pape | ||
| 3 | All rights reserved. | ||
| 4 | |||
| 5 | Redistribution and use in source and binary forms, with or without | ||
| 6 | modification, are permitted provided that the following conditions are met: | ||
| 7 | |||
| 8 | 1. Redistributions of source code must retain the above copyright notice, | ||
| 9 | this list of conditions and the following disclaimer. | ||
| 10 | 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | notice, this list of conditions and the following disclaimer in the | ||
| 12 | documentation and/or other materials provided with the distribution. | ||
| 13 | 3. The name of the author may not be used to endorse or promote products | ||
| 14 | derived from this software without specific prior written permission. | ||
| 15 | |||
| 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| 19 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
| 22 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 23 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 24 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 26 | */ | ||
| 27 | |||
| 28 | /* Taken from http://smarden.sunsite.dk/runit/sv.8.html: | ||
| 29 | |||
| 30 | sv - control and manage services monitored by runsv | ||
| 31 | |||
| 32 | sv [-v] [-w sec] command services | ||
| 33 | /etc/init.d/service [-w sec] command | ||
| 34 | |||
| 35 | The sv program reports the current status and controls the state of services | ||
| 36 | monitored by the runsv(8) supervisor. | ||
| 37 | |||
| 38 | services consists of one or more arguments, each argument naming a directory | ||
| 39 | service used by runsv(8). If service doesn?t start with a dot or slash, | ||
| 40 | it is searched in the default services directory /var/service/, otherwise | ||
| 41 | relative to the current directory. | ||
| 42 | |||
| 43 | command is one of up, down, status, once, pause, cont, hup, alarm, interrupt, | ||
| 44 | 1, 2, term, kill, or exit, or start, stop, restart, shutdown, force-stop, | ||
| 45 | force-reload, force-restart, force-shutdown. | ||
| 46 | |||
| 47 | The sv program can be sym-linked to /etc/init.d/ to provide an LSB init | ||
| 48 | script interface. The service to be controlled then is specified by the | ||
| 49 | base name of the "init script". | ||
| 50 | |||
| 51 | status | ||
| 52 | Report the current status of the service, and the appendant log service | ||
| 53 | if available, to standard output. | ||
| 54 | up | ||
| 55 | If the service is not running, start it. If the service stops, restart it. | ||
| 56 | down | ||
| 57 | If the service is running, send it the TERM signal, and the CONT signal. | ||
| 58 | If ./run exits, start ./finish if it exists. After it stops, do not | ||
| 59 | restart service. | ||
| 60 | once | ||
| 61 | If the service is not running, start it. Do not restart it if it stops. | ||
| 62 | pause cont hup alarm interrupt quit 1 2 term kill | ||
| 63 | If the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT, | ||
| 64 | USR1, USR2, TERM, or KILL signal respectively. | ||
| 65 | exit | ||
| 66 | If the service is running, send it the TERM signal, and the CONT signal. | ||
| 67 | Do not restart the service. If the service is down, and no log service | ||
| 68 | exists, runsv(8) exits. If the service is down and a log service exists, | ||
| 69 | send the TERM signal to the log service. If the log service is down, | ||
| 70 | runsv(8) exits. This command is ignored if it is given to an appendant | ||
| 71 | log service. | ||
| 72 | |||
| 73 | sv actually looks only at the first character of above commands. | ||
| 74 | |||
| 75 | status | ||
| 76 | Same as status. | ||
| 77 | start | ||
| 78 | Same as up, but wait up to 7 seconds for the command to take effect. | ||
| 79 | Then report the status or timeout. If the script ./check exists in | ||
| 80 | the service directory, sv runs this script to check whether the service | ||
| 81 | is up and available; it's considered to be available if ./check exits | ||
| 82 | with 0. | ||
| 83 | stop | ||
| 84 | Same as down, but wait up to 7 seconds for the service to become down. | ||
| 85 | Then report the status or timeout. | ||
| 86 | restart | ||
| 87 | Send the commands term, cont, and up to the service, and wait up to | ||
| 88 | 7 seconds for the service to restart. Then report the status or timeout. | ||
| 89 | If the script ./check exists in the service directory, sv runs this script | ||
| 90 | to check whether the service is up and available again; it's considered | ||
| 91 | to be available if ./check exits with 0. | ||
| 92 | shutdown | ||
| 93 | Same as exit, but wait up to 7 seconds for the runsv(8) process | ||
| 94 | to terminate. Then report the status or timeout. | ||
| 95 | force-stop | ||
| 96 | Same as down, but wait up to 7 seconds for the service to become down. | ||
| 97 | Then report the status, and on timeout send the service the kill command. | ||
| 98 | force-reload | ||
| 99 | Send the service the term and cont commands, and wait up to | ||
| 100 | 7 seconds for the service to restart. Then report the status, | ||
| 101 | and on timeout send the service the kill command. | ||
| 102 | force-restart | ||
| 103 | Send the service the term, cont and up commands, and wait up to | ||
| 104 | 7 seconds for the service to restart. Then report the status, and | ||
| 105 | on timeout send the service the kill command. If the script ./check | ||
| 106 | exists in the service directory, sv runs this script to check whether | ||
| 107 | the service is up and available again; it?s considered to be available | ||
| 108 | if ./check exits with 0. | ||
| 109 | force-shutdown | ||
| 110 | Same as exit, but wait up to 7 seconds for the runsv(8) process to | ||
| 111 | terminate. Then report the status, and on timeout send the service | ||
| 112 | the kill command. | ||
| 113 | |||
| 114 | Additional Commands | ||
| 115 | |||
| 116 | check | ||
| 117 | Check for the service to be in the state that's been requested. Wait up to | ||
| 118 | 7 seconds for the service to reach the requested state, then report | ||
| 119 | the status or timeout. If the requested state of the service is up, | ||
| 120 | and the script ./check exists in the service directory, sv runs | ||
| 121 | this script to check whether the service is up and running; | ||
| 122 | it's considered to be up if ./check exits with 0. | ||
| 123 | |||
| 124 | Options | ||
| 125 | |||
| 126 | -v | ||
| 127 | wait up to 7 seconds for the command to take effect. | ||
| 128 | Then report the status or timeout. | ||
| 129 | -w sec | ||
| 130 | Override the default timeout of 7 seconds with sec seconds. Implies -v. | ||
| 131 | |||
| 132 | Environment | ||
| 133 | |||
| 134 | SVDIR | ||
| 135 | The environment variable $SVDIR overrides the default services directory | ||
| 136 | /var/service. | ||
| 137 | SVWAIT | ||
| 138 | The environment variable $SVWAIT overrides the default 7 seconds to wait | ||
| 139 | for a command to take effect. It is overridden by the -w option. | ||
| 140 | |||
| 141 | Exit Codes | ||
| 142 | sv exits 0, if the command was successfully sent to all services, and, | ||
| 143 | if it was told to wait, the command has taken effect to all services. | ||
| 144 | |||
| 145 | For each service that caused an error (e.g. the directory is not | ||
| 146 | controlled by a runsv(8) process, or sv timed out while waiting), | ||
| 147 | sv increases the exit code by one and exits non zero. The maximum | ||
| 148 | is 99. sv exits 100 on error. | ||
| 149 | */ | ||
| 150 | |||
| 1 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ | 151 | /* Busyboxed by Denis Vlasenko <vda.linux@googlemail.com> */ |
| 2 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ | 152 | /* TODO: depends on runit_lib.c - review and reduce/eliminate */ |
| 3 | 153 | ||
