runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

sv.8 (6295B)


      1 .TH sv 8
      2 .SH NAME
      3 sv \- control and manage services monitored by
      4 .BR runsv (8)
      5 .SH SYNOPSIS
      6 .B sv
      7 [\-v] [\-w
      8 .I sec\fR]
      9 .I command
     10 .I services
     11 .P
     12 .BI /etc/init.d/ service
     13 [\-w
     14 .I sec\fR]
     15 .I command
     16 .SH DESCRIPTION
     17 The
     18 .B sv
     19 program reports the current status and controls the state of services
     20 monitored by the
     21 .BR runsv (8)
     22 supervisor.
     23 .P
     24 .I services
     25 consists of one or more arguments, each argument naming a directory
     26 .I service
     27 used by
     28 .BR runsv (8).
     29 If
     30 .I service
     31 doesn't start with a dot or slash and doesn't end with a slash, it is
     32 searched in the default services directory
     33 .IR /var/service/ ,
     34 otherwise relative to the current directory.
     35 .P
     36 .I command
     37 is one of up, down, status, once, pause, cont, hup, alarm, interrupt, 1, 2,
     38 term, kill, or exit, or start, stop, restart, shutdown, force-stop,
     39 force-reload, force-restart, force-shutdown.
     40 .P
     41 The
     42 .B sv
     43 program can be sym-linked to
     44 .I /etc/init.d/
     45 to provide an LSB init script interface.
     46 The
     47 .I service
     48 to be controlled then is specified by the base name of the ``init script''.
     49 .SH COMMANDS
     50 .TP
     51 .B status
     52 Report the current status of the service, and the appendant log service if
     53 available, to standard output.
     54 .TP
     55 .B up
     56 If the service is not running, start it.
     57 If the service stops, restart it.
     58 .TP
     59 .B down
     60 If the service is running, send it the TERM signal, and the CONT signal.
     61 If ./run exits, start ./finish if it exists.
     62 After it stops, do not restart service.
     63 .TP
     64 .B once
     65 If the service is not running, start it.
     66 Do not restart it if it stops.
     67 .TP
     68 .B pause cont hup alarm interrupt quit 1 2 term kill
     69 If the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT,
     70 USR1, USR2, TERM, or KILL signal respectively.
     71 .TP
     72 .B exit
     73 If the service is running, send it the TERM signal, and the CONT signal.
     74 Do not restart the service.
     75 If the service is down, and no log service exists,
     76 .BR runsv (8)
     77 exits.
     78 If the service is down and a log service exists,
     79 .BR runsv (8)
     80 closes the standard input of the log service and waits for it to terminate.
     81 If the log service is down,
     82 .BR runsv (8)
     83 exits.
     84 This command is ignored if it is given to an appendant log service.
     85 .P
     86 .BR sv
     87 actually looks only at the first character of these
     88 .IR command s.
     89 .SS Commands compatible to LSB init script actions
     90 .TP
     91 .B status
     92 Same as
     93 .IR status .
     94 .TP
     95 .B start
     96 Same as
     97 .IR up ,
     98 but wait up to 7 seconds for the command to take effect.
     99 Then report the status or timeout.
    100 If the script
    101 .I ./check
    102 exists in the service directory,
    103 .B sv
    104 runs this script to check whether the service is up and available;
    105 it's considered to be available if
    106 .I ./check
    107 exits with 0.
    108 .TP
    109 .B stop
    110 Same as
    111 .IR down ,
    112 but wait up to 7 seconds for the service to become down.
    113 Then report the status or timeout.
    114 .TP
    115 .B reload
    116 Same as
    117 .IR hup ,
    118 and additionally report the status afterwards.
    119 .TP
    120 .B restart
    121 Send the commands
    122 .IR term ,
    123 .IR cont ,
    124 and
    125 .I up
    126 to the service, and wait up to 7 seconds for the service to restart.
    127 Then report the status or timeout.
    128 If the script
    129 .I ./check
    130 exists in the service directory,
    131 .B sv
    132 runs this script to check whether the service is up and available again;
    133 it's considered to be available if
    134 .I ./check
    135 exits with 0.
    136 .TP
    137 .B shutdown
    138 Same as
    139 .IR exit ,
    140 but wait up to 7 seconds for the
    141 .BR runsv (8)
    142 process to terminate.
    143 Then report the status or timeout.
    144 .TP
    145 .B force-stop
    146 Same as
    147 .IR down ,
    148 but wait up to 7 seconds for the service to become down.
    149 Then report the status, and on timeout send the service the
    150 .I kill
    151 command.
    152 .TP
    153 .B force-reload
    154 Send the service the
    155 .I term
    156 and
    157 .I cont
    158 commands, and wait up to 7 seconds for the service to restart.
    159 Then report the status, and on timeout send the service the
    160 .I kill
    161 command.
    162 .TP
    163 .B force-restart
    164 Send the service the
    165 .IR term ,
    166 .I cont
    167 and
    168 .I up
    169 commands, and wait up to 7 seconds for the service to restart.
    170 Then report the status, and on timeout send the service the
    171 .I kill
    172 command.
    173 If the script
    174 .I ./check
    175 exists in the service directory,
    176 .B sv
    177 runs this script to check whether the service is up and available again;
    178 it's considered to be available if
    179 .I ./check
    180 exits with 0.
    181 .TP
    182 .B force-shutdown
    183 Same as
    184 .IR exit ,
    185 but wait up to 7 seconds for the
    186 .BR runsv (8)
    187 process to terminate.
    188 Then report the status, and on timeout send the service the
    189 .I kill
    190 command.
    191 .TP
    192 .B try-restart
    193 if the service is running, send it the
    194 .I term
    195 and
    196 .I cont
    197 commands, and wait up to 7 seconds for the service to restart.
    198 Then report the status or timeout.
    199 
    200 .SS Additional Commands
    201 .TP
    202 .B check
    203 Check for the service to be in the state that's been requested.
    204 Wait up to 7 seconds for the service to reach the requested state, then
    205 report the status or timeout.
    206 If the requested state of the service is
    207 .IR up ,
    208 and the script
    209 .I ./check
    210 exists in the service directory,
    211 .B sv
    212 runs this script to check whether the service is up and running; it's
    213 considered to be up if
    214 .I ./check
    215 exits with 0.
    216 .SH OPTIONS
    217 .TP
    218 .B \-v
    219 If the
    220 .I command
    221 is up, down, term, once, cont, or exit, then wait up to 7 seconds for the
    222 command to take effect.
    223 Then report the status or timeout.
    224 .TP
    225 .B \-w \fIsec
    226 Override the default timeout of 7 seconds with
    227 .I sec
    228 seconds.
    229 This option implies
    230 .IR \-v .
    231 .SH ENVIRONMENT
    232 .TP
    233 .B SVDIR
    234 The environment variable $SVDIR overrides the default services directory
    235 .IR /var/service/ .
    236 .TP
    237 .B SVWAIT
    238 The environment variable $SVWAIT overrides the default 7 seconds to wait
    239 for a command to take effect.
    240 It is overridden by the \-w option.
    241 .SH EXIT CODES
    242 .B sv
    243 exits 0, if the
    244 .I command
    245 was successfully sent to all
    246 .IR services ,
    247 and, if it was told to wait, the
    248 .I command
    249 has taken effect to all services.
    250 .P
    251 For each
    252 .I service
    253 that caused an error (e.g. the directory is not controlled by a
    254 .BR runsv (8)
    255 process, or
    256 .B sv
    257 timed out while waiting),
    258 .B sv
    259 increases the exit code by one and exits non zero.
    260 The maximum is 99.
    261 .B sv
    262 exits 100 on error.
    263 .P
    264 If
    265 .B sv
    266 is called with a base name other than
    267 .BR sv :
    268 it exits 1 on timeout or trouble sending the command; if the
    269 .I command
    270 is
    271 .BR status ,
    272 it exits 3 if the service is down, and 4 if the status is unknown;
    273 it exits 2 on wrong usage, and 151 on error.
    274 .SH SEE ALSO
    275 runsv(8),
    276 chpst(8),
    277 svlogd(8),
    278 runsvdir(8),
    279 runsvchdir(8),
    280 runit(8),
    281 runit-init(8)
    282 .P
    283 http://smarden.org/runit/
    284 .SH AUTHOR
    285 Gerrit Pape <pape@smarden.org>