summary refs log tree commit diff
path: root/doc/faq.html
blob: 7fdf734e14a6a5a39270d2aeb8bf117b49cd1a75 (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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>runit - Frequently asked questions</title>
</head>
<body>
<a href="http://smarden.org/pape/">G. Pape</a><br>
<a href="index.html">runit</a><br>
<hr>
<h1>runit - Frequently asked questions</h1>
<hr>
<a href="#what">
What's runit, why is it that different
</a><br>
<a href="#help">
I need some help with runit, what should I do
</a><br>
<!--
<a href="#service">
What is a service, what a service daemon
</a><br>
-->
<a href="#license">
What's the license, is runit free software
</a><br>
<p>
<a href="#run">
How do I run a service under runit service supervision
</a><br>
<a href="#create">
How do I create a new service directory
</a><br>
<!--
<a href="#log">
What is a log service
</a><br>
-->
<a href="#createlog">
How do I create a new service directory with an appendant log service
</a><br>
<a href="#tell">
How do I tell runit about a new service
</a><br>
<a href="#control">
How do I start, stop, or restart a service
</a><br>
<a href="#signal">
How can I send signals to a service daemon
</a><br>
<a href="#status"> 
How can I query the status of a service
</a><br>
<a href="#remove">
How do I remove a service
</a><br>
<p>
<a href="#depends">
How do I make a service depend on another service
</a><br>
<!--
<a href="#strongdepends">
How can I make a service affect a dependant service
</a><br>
-->
<p>
<a href="#runlevels">
What about runlevels
</a><br>
<a href="#lsb">
What about LSB init scripts compliance
</a><br>
<p>
<a href="#user">
Is it possible to allow a user other than root to control a service
</a><br>
<a href="#userservices">
Does runit support user-specific services?
</a><br>
<a href="#readonlyfs">
Does runit work on a read-only filesystem
</a><br>

<hr>
<a name="what"><h3>
What's runit, why is it that different
</h3></a>
What is this runit init scheme about? 
Why is it that different from sysvinit and other init schemes?
<p>
Answer:
Please see the <a href="index.html">introduction</a>, and web page about
runit's <a href="benefits.html">benefits</a>.

<hr>
<a name="help"><h3>
I need some help with runit, what should I do
</h3></a>
I have a question, runit is doing something wrong, or I'm doing something
wrong, what should I do?
<p>
Answer:
First see the documentation, especially this list of
<a href="faq.html">frequently asked questions</a>, and the man pages
if you have a question about a specific runit program.
If that still doesn't answer your question, try to search the
<a href="http://news.gmane.org/gmane.comp.sysutils.supervision.general">
supervision mailing list archive</a>.
Finally, if this fails, feel free to post your question to the
<a href="http://skarnet.org/lists/">supervision mailing list</a>.

<!--
<hr>
<a name="service"><h3>
What is a service, what a service daemon
</h3></a>
The runit documentation talks about services and service daemons.
What actually is a service, and what a service daemon?
<p>
Answer:
-->

<hr>
<a name="license"><h3>
What's the license, is runit free software
</h3></a>
I would like to distribute runit, in source and binary form.
Am I allowed to do so?
<p>
Answer:
runit is free software, it's licensed under a three-clause BSD alike
license.
See the file <tt>package/COPYING</tt> in the runit tarball.

<hr>
<a name="run"><h3>
How do I run a service under runit service supervision
</h3></a>
I want a service to be run under runit service supervision, so that it's
automatically started on system boot, and supervised while system uptime.
How does that work?
<p>
Answer:
runit doesn't use the usual <tt>/etc/init.d/</tt> init script interface,
but uses a directory per service.
To integrate a service into the runit init scheme,
<a href="#create">create a service directory</a> for the service, and
<a href="#tell">tell runit</a> about it.

<hr>
<a name="create"><h3>
How do I create a new service directory
</h3></a>
How do I create a service directory for the use with runit?
<p>
Answer:
Service directories usually are placed into the <tt>/etc/sv/</tt>
directory.
Create a new directory for your service in <tt>/etc/sv/</tt>, put a
<tt>./run</tt> script into it, and make the script executable.
Note that for the use with runit,
<a href="#service">service daemons</a> must not put themself into the
background, but must run in the foreground.
Here's a simple example for a <tt>getty</tt> service:
<pre>
 $ cat /etc/sv/getty-2/run
 #!/bin/sh
 exec getty 38400 tty2 linux
 $ 
</pre>
Note the <tt>exec</tt> in the last line, it tells the shell that
interprets the script to replace itself with the service daemon
<tt>getty</tt>; this is necessary to make
<a href="#control">controlling the service</a> work properly.

<!--
<hr>
<a name="log"><h3>
What is a log service
</h3></a>
Additionally to supervising a service runit can supervise an appendant
log service.
What does that mean?
<p>
Answer:
-->

<hr>
<a name="createlog"><h3>
How do I create a new service directory with an appendant log service
</h3></a>
How do I create a service directory with an appendant log service for the
use with runit?
<p>
Answer:
First <a href="#create">create the service directory</a> for the service.
Then create a subdirectory <tt>./log</tt> in the service directory, again
put a <tt>./run</tt> script into it, and make the script executable.
The <tt>./run</tt> script must run a service logging daemon, normally
this is the <a href="svlogd.8.html">svlogd</a> program.
See the <a href="runsv.8.html">runsv</a> man page for details.
Here's an example of a <tt>./log/run</tt> script:
<pre>
 $ cat /etc/sv/socklog-klog/log/run
 #!/bin/sh
 exec chpst -ulog svlogd -tt ./main
 $ 
</pre>

<hr>
<a name="tell"><h3>
How do I tell runit about a new service
</h3></a>
I created a service directory for a service that should run under runit
service supervision.
How do I tell runit about the new service directory, so that it picks
up and runs the service by default?
<p>
Answer:
Create a symbolic link in <tt>/var/service/</tt> pointing to the service
directory, runit will pick up the service within the next five seconds,
and automatically start it on system boot.
E.g.:
<pre>
 # ln -s /etc/sv/getty-2 /var/service/
</pre>

<hr>
<a name="control"><h3>
How do I start, stop, or restart a service
</h3></a>
I want to stop a service temporarily, and probably restart is later, or
I want to have it restarted immediately.
How can I control a service running under runit service supervision?
<p>
Answer:
Use the <a href="sv.8.html">sv</a> program.
E.g., to restart the <tt>socklog-unix</tt> service, do:
<pre>
 # sv restart socklog-unix
</pre>

<hr>
<a name="signal"><h3>
How can I send signals to a service daemon
</h3></a>
I want to send a service daemon the HUP signal, to have it re-read its
configuration, or I want to send it the INT signal.
How can a send signals to a service daemon?
<p>
Answer:
Use the <a href="sv.8.html">sv</a> program.
E.g., to send the <tt>dhcp</tt> service the HUP signal, do:
<pre>
 # sv hup dhcp
</pre>

<hr>
<a name="status"><h3>
How can I query the status of a service
</a></h3>
I want to now the status of a service, whether it is up and available,
or down as requested, or so.
How can I find out this information?
<p>
Answer:
User the <a href="sv.8.html">sv</a> program.
E.g., to query or check the status of the <tt>socklog-unix</tt> service,
do:
<pre>
 # sv status socklog-unix
</pre>
or
<pre>
 # sv check socklog-unix
</pre>

<hr>
<a name="remove"><h3>
How do I remove a service
</h3></a>
I want to remove a service that currently runs under runit service
supervision.
How do I tell runit?
<p>
Answer:
Remove the symbolic link in <tt>/var/service/</tt> pointing to the service
directory, runit recognizes the removed service within the next five
seconds, then stops the service, the optional log service, and finally the
supervisor process.
E.g.:
<pre>
 # rm /var/service/getty-2
</pre>

<hr>
<a name="depends"><h3>
How do I make a service depend on another service
</a></h3>
I have a service that needs another service to be available before it can
start.
How can I tell runit about this dependency?
<p>
Answer:
Make sure in the <tt>./run</tt> script of the dependant service that the
service it depends on is available before the service daemon starts.
The <a href="sv.8.html">sv</a> program can be used for that.
E.g. the <tt>cron</tt> service wants the <tt>socklog-unix</tt> system
logging service to be available before starting the <tt>cron</tt> service
daemon, so no logs get lost:
<pre>
 $ cat /etc/sv/cron/run
 #!/bin/sh
 sv start socklog-unix || exit 1
 exec cron -f
 $ 
</pre>
See also the <a href="dependencies.html">documentation</a>.

<!--
<hr>
<a name="strongdepends"><h3>
How can I make a service affect a dependant service
</a></h3>
<a href="#depends">This dependency</a> is not enough.
I have a service that needs to be stopped or restarted, whenever a service
it depends on stops or restarts.
How can I tell runit about that a service affects a dependant service in
such a way?
<p>
Answer:
First think about whether you really need this, it almost never should be
necessary.
If you really need this,
-->

<hr>
<a name="runlevels"><h3>
What about runlevels
</a></h3>
Other init schemes support runlevels, what about runit?
<p>
Answer:
runit supports runlevels, even more flexible than traditional init schemes.
See <a href="runlevels.html">the documentation</a>.

<hr>
<a name="lsb"><h3>
What about LSB init scripts compliance
</a></h3>
I know about the <a href="sv.8.html">sv</a> program to control a service,
but have applications that rely on the <tt>/etc/init.d/</tt> scripts
interface as defined through LSB.
Do I need to change the application to work with runit?
<p>
Answer:
You don't need to change the application.
The <a href="sv.8.html">sv</a> program supports the <tt>/etc/init.d/</tt>
script interface
<a href="http://refspecs.freestandards.org/LSB_2.1.0/LSB-generic/LSB-generic/iniscrptact.html">
as defined through LSB</a>.
To make this script interface work for a service, create a symbolic link
in <tt>/etc/init.d/</tt>, named as the service daemon, pointing to the
<a href="sv.8.html">sv</a> program, e.g. for the <tt>cron</tt> service:
<pre>
 # ln -s /bin/sv /etc/init.d/cron
 # /etc/init.d/cron restart
 ok: run: cron: (pid 5869) 0s
 # 
</pre>

<hr>
<a name="user"><h3>
Is it possible to allow a user other than root to control a service
</a></h3>
Using the <a href="sv.8.html">sv</a> program to control a service, or query
its status informations, only works as root.
Is it possible to allow non-root users to control a service too?
<p>
Answer:
Yes, you simply need to adjust file system permissions for the
<tt>./supervise/</tt> subdirectory in the service directory.
E.g.: to allow the user <tt>burdon</tt> to control the service
<tt>dhcp</tt>, change to the <tt>dhcp</tt> service directory, and do
<pre>
 # chmod 755 ./supervise
 # chown burdon ./supervise/ok ./supervise/control ./supervise/status
</pre>
This works similarly with groups, of course.

<hr>
<a name="userservices"><h3>
Does runit support user-specific services?
</a></h3>
It's very nice to simply
<a href="#tell">create symbolic links</a> to add system-wide services.
Does this work for user-specific services too?
<p>
Answer:
Yes.
E.g.: to provide the user <tt>floyd</tt> with facility to manage services
through <tt>~/service/</tt>, <a href="#createlog">create a service</a>
<tt>runsvdir-floyd</tt> with the following run script and a usual log/run
script, and <a href="#tell">tell runit</a> about the service
<pre>
 #!/bin/sh
 exec 2>&1
 exec chpst -ufloyd runsvdir /home/floyd/service
</pre>
Now <tt>floyd</tt> can create services on his own, and manage them through
symbolic links in <tt>~/service/</tt> to have them run under his user id.

<hr>
<a name="readonlyfs"><h3>
Does runit work on a read-only filesystem
</a></h3>
On my system <tt>/etc/</tt> is mounted read-only by default.
runit uses many files in <tt>/etc/</tt> it needs to write to, like
<tt>/etc/runit/stopit</tt>, and the <tt>./supervise/</tt>
subdirectories in the service directories.
How can I make runit work on my system?
<p>
Answer:
Use symbolic links, runit deals with them well, even with dangling
symlinks.
E.g., make a ramdisk available at a moint point, say <tt>/var/run/</tt>,
and create symbolic links for the files and directories that runit needs
to write access to pointing into <tt>/var/run/</tt>:
<pre>
 # ln -s /var/run/runit.stopit /etc/runit/stopit
 # ln -s /var/run/sv.getty-2 /etc/sv/getty-2/supervise
</pre>

<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape &lt;pape@smarden.org&gt;
</a></address>
</body>
</html>