File: dependencies.html

package info (click to toggle)
runit 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,220 kB
  • sloc: ansic: 5,572; sh: 3,588; makefile: 383
file content (71 lines) | stat: -rw-r--r-- 2,327 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>runit -service dependencies</title>
</head>
<body>
<a href="https://smarden.org/pape/">G. Pape</a><br>
<a href="index.html">runit</a><br>
<hr>
<h1>runit - service dependencies</h1>
<hr>
<i>runit</i>&rsquo;s service supervision resolves dependencies automatically
for many or even most service daemons, those that exit if another service
they need to function properly is not or no longer available.
The <a href="https://smarden.org/runit/runsv.8.html">runsv</a> supervisor
will then start them again, until everything is in shape.
<hr>
For service daemons with different behavior, or to arrange services more
structurally, the <a href="https://smarden.org/runit/sv.8.html">sv</a>
program can help.  A few examples:
<p>
For the service daemon <i>floyd</i>, that needs the <i>pinkd</i> service up
and running, add <tt>sv start pinkd</tt> to <i>floyd</i>&rsquo;s
<tt>run</tt> script, right after <tt>set -e</tt>.
<pre>
 #!/bin/sh
 set -e
 sv start pinkd
 exec floyd
</pre>
<p>
When the <i>pinkd</i> service daemon crashes or is restarted for other
reasons and the <i>floyd</i> daemon is unable to handle this, add <tt>sv hup
floyd</tt> (or whatever the <i>floyd</i> daemon understands) to
<i>pinkd</i>&rsquo;s <tt>finish</tt> script to force its reload or restart.
<pre>
 #!/bin/sh
 sv hup floyd
</pre>
<p>
If the <i>pinkd</i> service shall be stopped when the <i>floyd</i> service
is stopped gracefully, add <tt>test "$1" != 0 || sv down pinkd</tt> to
<i>floyd</i>&rsquo;s <tt>finish</tt> script.
<pre>
 #!/bin/sh
 test "$1" != 0 || sv down pinkd
</pre>
Or vice versa.
<p>
Explore the <a href="https://smarden.org/runit/sv.8.html">sv</a> program for
more options.
<hr>
For service daemons that do not make their service available immediately
after starting, a <tt>check</tt> script can be added.
The <a href="https://smarden.org/runit/sv.8.html">sv</a> program will use
this <tt>check</tt> script to better evaluate whether a service is fully
started and available, for example:
<p>
For a mail service listening on localhost:25, this <tt>check</tt> script
could be used
<pre>
 #!/bin/sh
 set -e
 exec nc -z localhost 25
</pre>
<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape &lt;pape@smarden.org&gt;
</a></address>
</body>
</html>