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