summary refs log tree commit diff
path: root/doc/runsv.8.html
blob: 94ebde9eec2d63eb357bdc2bb6303ed38354fe55 (plain) (blame)
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



<html>
<head>
<title>runsv(8) manual page</title>
</head>
<body bgcolor='white'>
<a href='http://smarden.org/pape/'>G. Pape</a><br><a href='index.html'>runit</A><hr><p>

<h2><a name='sect0'>Name</a></h2>
runsv - starts and monitors a service and optionally an appendant log
service 
<h2><a name='sect1'>Synopsis</a></h2>
<b>runsv</b> <i>service</i> 
<h2><a name='sect2'>Description</a></h2>
<i>service</i> must be a directory. <p>
<b>runsv</b>
switches to the directory <i>service</i> and starts ./run. If ./run exits and ./finish
exists, <b>runsv</b> starts ./finish. If ./finish doesn&rsquo;t exist or ./finish exits,
<b>runsv</b> restarts ./run. <p>
If ./run or ./finish exit immediately, <b>runsv</b> waits a
second before starting ./finish or restarting ./run. <p>
If the file <i>service</i>/down
exists, <b>runsv</b> does not start ./run immediately. The control interface (see
below) can be used to start the service and to give other commands to <b>runsv</b>.
<p>
If the directory <i>service</i>/log exists, <b>runsv</b> creates a pipe, redirects <i>service</i>/run&rsquo;s
and <i>service</i>/finish&rsquo;s standard output to the pipe, switches to the directory
<i>service</i>/log and starts ./run (and ./finish) exactly as described above for
the <i>service</i> directory. The standard input of the log service is redirected
to read from the pipe. <p>
<b>runsv</b> maintains status information in a binary format
(compatible to the daemontools&rsquo; <b>supervise</b> program) in <i>service</i>/supervise/status
and <i>service</i>/log/supervise/status, and in a human-readable format in <i>service</i>/supervise/stat,
<i>service</i>/log/supervise/stat, <i>service</i>/supervise/pid, <i>service</i>/log/supervise/pid.

<h2><a name='sect3'>Control</a></h2>
The named pipes <i>service</i>/supervise/control, and (optionally) <i>service</i>/log/supervise/control
are provided to give commands to <b>runsv</b>. You can use <i><b>sv</b>(8)</i> to control the
service or just write one of the following characters to the named pipe:

<dl>

<dt><b>u</b> </dt>
<dd>Up. If the service is not running, start it. If the service stops, restart
it. </dd>

<dt><b>d</b> </dt>
<dd>Down. If the service is running, send it a TERM signal, and then a
CONT signal. If ./run exits, start ./finish if it exists. After it stops, do
not restart service. </dd>

<dt><b>o</b> </dt>
<dd>Once. If the service is not running, start it. Do not
restart it if it stops. </dd>

<dt><b>p</b> </dt>
<dd>Pause. If the service is running, send it a STOP
signal. </dd>

<dt><b>c</b> </dt>
<dd>Continue. If the service is running, send it a CONT signal. </dd>

<dt><b>h</b> </dt>
<dd>Hangup.
If the service is running, send it a HUP signal. </dd>

<dt><b>a</b> </dt>
<dd>Alarm. If the service
is running, send it a ALRM signal. </dd>

<dt><b>i</b> </dt>
<dd>Interrupt. If the service is running,
send it a INT signal. </dd>

<dt><b>q</b> </dt>
<dd>Quit. If the service is running, send it a QUIT signal. </dd>

<dt><b>1</b> </dt>
<dd>User-defined 1. If the service is running, send it a USR1 signal. </dd>

<dt><b>2</b> </dt>
<dd>User-defined 2. If the service is running, send it a USR2 signal. </dd>

<dt><b>t</b> </dt>
<dd>Terminate. If the service
is running, send it a TERM signal. </dd>

<dt><b>k</b> </dt>
<dd>Kill. If the service is running, send
it a KILL signal. </dd>

<dt><b>x</b> </dt>
<dd>Exit. If the service is running, send it a TERM signal,
and then a CONT signal. Do not restart the service. If the service is down,
and no log service exists, <b>runsv</b> exits. If the service is down and a log
service exists, <b>runsv</b> closes the standard input of the log service, and
waits for it to terminate. If the log service is down, <b>runsv</b> exits. This
command is ignored if it is given to <i>service</i>/log/supervise/control. </dd>
</dl>
<p>
Example:
to send a TERM signal to the socklog-unix service, either do   # sv term
/var/service/socklog-unix<br>
  or<br>
   # echo -n t &gt;/var/service/socklog-unix/supervise/control<br>
 <p>
If <i><b>echo</b>(1)</i> on your systems does not provide the -n option, leave it out,
<b>runsv</b> ignores unknown characters written to the control pipe. <i><b>echo</b>(1)</i> usually
blocks if no <b>runsv</b> process is running in the service directory. 
<h2><a name='sect4'>Customize
Control</a></h2>
For each control character <i>c</i> sent to the control pipe, <b>runsv</b> first
checks if <i>service/control/<i>c</i> exists and is executable. If so, it starts <i>service</i>/control/<i>c</i>
and waits for it to terminate, before interpreting the command. If the program
exits with return code 0, <b>runsv</b> refrains from sending the service the corresponding
signal. The command <i>o</i> is always considered as command <i>u</i>. On command <i>d</i> first
<i>service</i>/control/t</i> is checked, and then <i>service/control/d.</i> On command <i>x</i> first
<i>service/control/t</i> is checked, and then <i>service/control/x.</i> The control of
the optional log service cannot be customized. 
<h2><a name='sect5'>Signals</a></h2>
If <b>runsv</b> receives
a TERM signal, it acts as if the character x was written to the control
pipe. 
<h2><a name='sect6'>Exit Codes</a></h2>
<b>runsv</b> exits 111 on an error on startup or if another <b>runsv</b>
is running in <i>service</i>. <p>
<b>runsv</b> exits 0 if it was told to exit. 
<h2><a name='sect7'>See Also</a></h2>
<i>sv(8)</i>,
<i>chpst(8)</i>, <i>svlogd(8)</i>, <i>runit(8)</i>, <i>runit-init(8)</i>, <i>runsvdir(8)</i>, <i>runsvchdir(8)</i>,
<i>utmpset(8)</i> <p>
<i>http://smarden.org/runit/</i> 
<h2><a name='sect8'>Author</a></h2>
Gerrit Pape &lt;pape@smarden.org&gt; <p>

<hr><p>
<a name='toc'><b>Table of Contents</b></a><p>
<ul>
<li><a name='toc0' href='#sect0'>Name</a></li>
<li><a name='toc1' href='#sect1'>Synopsis</a></li>
<li><a name='toc2' href='#sect2'>Description</a></li>
<li><a name='toc3' href='#sect3'>Control</a></li>
<li><a name='toc4' href='#sect4'>Customize Control</a></li>
<li><a name='toc5' href='#sect5'>Signals</a></li>
<li><a name='toc6' href='#sect6'>Exit Codes</a></li>
<li><a name='toc7' href='#sect7'>See Also</a></li>
<li><a name='toc8' href='#sect8'>Author</a></li>
</ul>
</body>
</html>