sv.8.html (8417B)
1 2 3 4 <html> 5 <head> 6 <title>sv(8) manual page</title> 7 </head> 8 <body bgcolor='white'> 9 <a href='http://smarden.org/pape/'>G. Pape</a><br><a href='index.html'>runit</A><hr><p> 10 11 <h2><a name='sect0'>Name</a></h2> 12 sv - control and manage services monitored by <i><b>runsv</b>(8)</i> 13 <h2><a name='sect1'>Synopsis</a></h2> 14 <b>sv</b> [-v] 15 [-w <i>sec]</i> <i>command</i> <i>services</i> <p> 16 <b>/etc/init.d/</b><i>service</i> [-w <i>sec]</i> <i>command</i> 17 <h2><a name='sect2'>Description</a></h2> 18 The 19 <b>sv</b> program reports the current status and controls the state of services 20 monitored by the <i><b>runsv</b>(8)</i> supervisor. <p> 21 <i>services</i> consists of one or more arguments, 22 each argument naming a directory <i>service</i> used by <i><b>runsv</b>(8)</i>. If <i>service</i> doesn’t 23 start with a dot or slash and doesn’t end with a slash, it is searched in 24 the default services directory <i>/service/</i>, otherwise relative to the current 25 directory. <p> 26 <i>command</i> is one of up, down, status, once, pause, cont, hup, alarm, 27 interrupt, 1, 2, term, kill, or exit, or start, stop, restart, shutdown, 28 force-stop, force-reload, force-restart, force-shutdown. <p> 29 The <b>sv</b> program can 30 be sym-linked to <i>/etc/init.d/</i> to provide an LSB init script interface. The 31 <i>service</i> to be controlled then is specified by the base name of the ‘‘init 32 script’’. 33 <h2><a name='sect3'>Commands</a></h2> 34 35 <dl> 36 37 <dt><b>status</b> </dt> 38 <dd>Report the current status of the service, and the 39 appendant log service if available, to standard output. </dd> 40 41 <dt><b>up</b> </dt> 42 <dd>If the service 43 is not running, start it. If the service stops, restart it. </dd> 44 45 <dt><b>down</b> </dt> 46 <dd>If the service 47 is running, send it the TERM signal, and the CONT signal. If ./run exits, 48 start ./finish if it exists. After it stops, do not restart service. </dd> 49 50 <dt><b>once</b> 51 </dt> 52 <dd>If the service is not running, start it. Do not restart it if it stops. </dd> 53 54 <dt><b>pause 55 cont hup alarm interrupt quit 1 2 term kill</b> </dt> 56 <dd>If the service is running, 57 send it the STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, or KILL 58 signal respectively. </dd> 59 60 <dt><b>exit</b> </dt> 61 <dd>If the service is running, send it the TERM signal, 62 and the CONT signal. Do not restart the service. If the service is down, 63 and no log service exists, <i><b>runsv</b>(8)</i> exits. If the service is down and a 64 log service exists, <i><b>runsv</b>(8)</i> closes the standard input of the log service 65 and waits for it to terminate. If the log service is down, <i><b>runsv</b>(8)</i> exits. 66 This command is ignored if it is given to an appendant log service. </dd> 67 </dl> 68 <p> 69 <b>sv</b> actually 70 looks only at the first character of these <i>command</i>s. 71 <h3><a name='sect4'>Commands compatible 72 to LSB init script actions</a></h3> 73 74 <dl> 75 76 <dt><b>status</b> </dt> 77 <dd>Same as <i>status</i>. </dd> 78 79 <dt><b>start</b> </dt> 80 <dd>Same as <i>up</i>, but wait 81 up to 7 seconds for the command to take effect. Then report the status or 82 timeout. If the script <i>./check</i> exists in the service directory, <b>sv</b> runs this 83 script to check whether the service is up and available; it’s considered 84 to be available if <i>./check</i> exits with 0. </dd> 85 86 <dt><b>stop</b> </dt> 87 <dd>Same as <i>down</i>, but wait up to 88 7 seconds for the service to become down. Then report the status or timeout. 89 </dd> 90 91 <dt><b>reload</b> </dt> 92 <dd>Same as <i>hup</i>, and additionally report the status afterwards. </dd> 93 94 <dt><b>restart</b> 95 </dt> 96 <dd>Send the commands <i>term</i>, <i>cont</i>, and <i>up</i> to the service, and wait up to 7 seconds 97 for the service to restart. Then report the status or timeout. If the script 98 <i>./check</i> exists in the service directory, <b>sv</b> runs this script to check whether 99 the service is up and available again; it’s considered to be available if 100 <i>./check</i> exits with 0. </dd> 101 102 <dt><b>shutdown</b> </dt> 103 <dd>Same as <i>exit</i>, but wait up to 7 seconds for 104 the <i><b>runsv</b>(8)</i> process to terminate. Then report the status or timeout. </dd> 105 106 <dt><b>force-stop</b> 107 </dt> 108 <dd>Same as <i>down</i>, but wait up to 7 seconds for the service to become down. Then 109 report the status, and on timeout send the service the <i>kill</i> command. </dd> 110 111 <dt><b>force-reload</b> 112 </dt> 113 <dd>Send the service the <i>term</i> and <i>cont</i> commands, and wait up to 7 seconds for 114 the service to restart. Then report the status, and on timeout send the 115 service the <i>kill</i> command. </dd> 116 117 <dt><b>force-restart</b> </dt> 118 <dd>Send the service the <i>term</i>, <i>cont</i> and 119 <i>up</i> commands, and wait up to 7 seconds for the service to restart. Then report 120 the status, and on timeout send the service the <i>kill</i> command. If the script 121 <i>./check</i> exists in the service directory, <b>sv</b> runs this script to check whether 122 the service is up and available again; it’s considered to be available if 123 <i>./check</i> exits with 0. </dd> 124 125 <dt><b>force-shutdown</b> </dt> 126 <dd>Same as <i>exit</i>, but wait up to 7 seconds 127 for the <i><b>runsv</b>(8)</i> process to terminate. Then report the status, and on timeout 128 send the service the <i>kill</i> command. </dd> 129 130 <dt><b>try-restart</b> </dt> 131 <dd>if the service is running, 132 send it the <i>term</i> and <i>cont</i> commands, and wait up to 7 seconds for the service 133 to restart. Then report the status or timeout. 134 <p> </dd> 135 </dl> 136 137 <h3><a name='sect5'>Additional Commands</a></h3> 138 139 <dl> 140 141 <dt><b>check</b> 142 </dt> 143 <dd>Check for the service to be in the state that’s been requested. Wait up to 144 7 seconds for the service to reach the requested state, then report the 145 status or timeout. If the requested state of the service is <i>up</i>, and the 146 script <i>./check</i> exists in the service directory, <b>sv</b> runs this script to check 147 whether the service is up and running; it’s considered to be up if <i>./check</i> 148 exits with 0. </dd> 149 </dl> 150 151 <h2><a name='sect6'>Options</a></h2> 152 153 <dl> 154 155 <dt><b>-v</b> </dt> 156 <dd>If the <i>command</i> is up, down, term, once, cont, or 157 exit, then wait up to 7 seconds for the command to take effect. Then report 158 the status or timeout. </dd> 159 160 <dt><b>-w <i>sec</b> </i></dt> 161 <dd>Override the default timeout of 7 seconds with 162 <i>sec</i> seconds. This option implies <i>-v</i>. </dd> 163 </dl> 164 165 <h2><a name='sect7'>Environment</a></h2> 166 167 <dl> 168 169 <dt><b>SVDIR</b> </dt> 170 <dd>The environment variable 171 $SVDIR overrides the default services directory <i>/service/</i>. </dd> 172 173 <dt><b>SVWAIT</b> </dt> 174 <dd>The environment 175 variable $SVWAIT overrides the default 7 seconds to wait for a command 176 to take effect. It is overridden by the -w option. </dd> 177 </dl> 178 179 <h2><a name='sect8'>Exit Codes</a></h2> 180 <b>sv</b> exits 0, if 181 the <i>command</i> was successfully sent to all <i>services</i>, and, if it was told 182 to wait, the <i>command</i> has taken effect to all services. <p> 183 For each <i>service</i> 184 that caused an error (e.g. the directory is not controlled by a <i><b>runsv</b>(8)</i> 185 process, or <b>sv</b> timed out while waiting), <b>sv</b> increases the exit code by 186 one and exits non zero. The maximum is 99. <b>sv</b> exits 100 on error. <p> 187 If <b>sv</b> is 188 called with a base name other than <b>sv</b>: it exits 1 on timeout or trouble 189 sending the command; if the <i>command</i> is <b>status</b>, it exits 3 if the service 190 is down, and 4 if the status is unknown; it exits 2 on wrong usage, and 191 151 on error. 192 <h2><a name='sect9'>See Also</a></h2> 193 <i>runsv(8)</i>, <i>chpst(8)</i>, <i>svlogd(8)</i>, <i>runsvdir(8)</i>, <i>runsvchdir(8)</i>, 194 <i>runit(8)</i>, <i>runit-init(8)</i> <p> 195 <i>http://smarden.org/runit/</i> 196 <h2><a name='sect10'>Author</a></h2> 197 Gerrit Pape <pape@smarden.org> 198 <p> 199 200 <hr><p> 201 <a name='toc'><b>Table of Contents</b></a><p> 202 <ul> 203 <li><a name='toc0' href='#sect0'>Name</a></li> 204 <li><a name='toc1' href='#sect1'>Synopsis</a></li> 205 <li><a name='toc2' href='#sect2'>Description</a></li> 206 <li><a name='toc3' href='#sect3'>Commands</a></li> 207 <ul> 208 <li><a name='toc4' href='#sect4'>Commands compatible to LSB init script actions</a></li> 209 <li><a name='toc5' href='#sect5'>Additional Commands</a></li> 210 </ul> 211 <li><a name='toc6' href='#sect6'>Options</a></li> 212 <li><a name='toc7' href='#sect7'>Environment</a></li> 213 <li><a name='toc8' href='#sect8'>Exit Codes</a></li> 214 <li><a name='toc9' href='#sect9'>See Also</a></li> 215 <li><a name='toc10' href='#sect10'>Author</a></li> 216 </ul> 217 </body> 218 </html>