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
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>runit - minimal replacement for sysvinit</title>
</head>
<body>
<a href="http://smarden.org/pape/">G. Pape</a>
<hr>
<h1>runit - minimal replacement for <i>sysvinit</i></h1>
<hr>
<a href="install.html">How to install runit</a><br>
<a href="replaceinit.html">How to replace init</a><br>
<a href="usedietlibc.html">How to use dietlibc</a>
<p>
<a href="runscripts.html">A collection of run scripts</a><br>
<a href="http://smarden.org/pape/djb/daemontools/noinit.html">
Dependencies and runlevels</a>
<p>
<a href="runit.8.html">The <tt>runit</tt> program</a><br>
<a href="runit-init.8.html">The <tt>runit-init</tt> program</a><br>
<a href="svwaitdown.8.html">The <tt>svwaitdown</tt> program</a><br>
<a href="svwaitup.8.html">The <tt>svwaitup</tt> program</a>
<hr>
<i>runit</i> cooperates with the
<a href="http://cr.yp.to/daemontools.html">daemontools</a> package to create
a replacement for
<a href="ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/">sysvinit</a>.
<i>runit</i> runs on <b>Debian GNU/Linux sid/woody</b>,
<b>OpenBSD 2.9</b>, <b>FreeBSD 4.4</b>. <i>runit</i> reportedly runs on
<b>FreeBSD 4.3</b>, and can easily be adapted to other unix operating
systems. If <i>runit</i> runs for you on any other operating system or
linux distribution, please let me know.
<p>
<b>Warning:</b> Replacing <i>sysvinit</i> or <i>init</i> can cause the
system's boot to fail. Make sure you are able to recover and repair your
system, for example if you run a boot loader, it should be able to pass
<tt>init=/bin/sh</tt> to the kernel.
<hr>
The command <a href="runit.8.html">runit</a> is intended to run as Unix
process no 1, it is automatically started by the
<a href="runit-init.8.html">runit-init</a> <tt>/sbin/init</tt>-replacement
if this is started by the kernel.
<p>
<a href="runit.8.html">runit</a> performs the system's <i>booting</i>,
<i>running</i> and <i>shutting down</i> in <b>three stages</b>:
<ul>
<li><b>Stage 1:</b><br>
<i>runit</i> starts <tt>/etc/runit/1</tt> and waits for it to
terminate. The system's one time initialization tasks are done here.
<tt>/etc/runit/1</tt> has full control of <tt>/dev/console</tt> to be
able to start an emergency shell if the one time initialization tasks
fail.
<li><b>Stage 2:</b><br>
<i>runit</i> starts <tt>/etc/runit/2</tt> which should not return
until the system is going to halt or reboot, if it crashes, it will be
restarted. Normally, <tt>/etc/runit/2</tt> runs
<a href="http://cr.yp.to/daemontools/svscanboot.html">svscanboot</a>.
In Stage 2 <i>runit</i> optionally handles an INT signal
(ctrl-alt-del keyboard request on Linux/i386).
<li><b>Stage 3:</b><br>
If <i>runit</i> is told to halt or reboot the system, or the Stage 2
returns without errors, it terminates Stage 2 if it is running and runs
<tt>/etc/runit/3</tt>. The systems tasks to shutdown and halt or
reboot are done here.
</ul>
These are working examples for debian woody:
<a href="debian/1">/etc/runit/1</a>,
<a href="debian/2">/etc/runit/2</a>,
<a href="debian/3">/etc/runit/3</a>.
<p>
The command <a href="runit-init.8.html">runit-init</a> is intended to
replace <tt>/sbin/init</tt>. sysvinit's command <tt>shutdown</tt> will
keep working. On *BSD systems use <b><tt>init 0</tt></b> for system halt
and <b><tt>init 6</tt></b> for reboot. Runlevels are not implemented in
this Unix process no 1, such can easily be done in other programs, see
<a href="http://smarden.org/pape/djb/daemontools/noinit.html">
Dependencies and runlevels</a>
for an example, the amount of code in process no 1 should be minimal.
<hr>
<b><i>runit</i> in use</b>: I replaced <i>sysvinit</i> with <i>runit</i>
on several server systems and a laptop, all running Debian/GNU Linux woody
or potato, some months ago and did not encounter any problems.
This is from the second machine where I replaced <i>sysvinit</i> with
<i>runit</i>:
<pre>
# strings /proc/1/exe |grep Id
$Id: runit.c,v 1.5 2001/12/30 16:28:53 pape Exp $
# uptime
10:35:18 up 107 days, 15:46, 2 users, load average: 0.00, 0.00, 0.00
# ps axuw |head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 24 24 ? S 2001 0:06 runit
root 2 0.0 0.0 0 0 ? SW 2001 0:07 [kflushd]
root 3 0.0 0.0 0 0 ? SW 2001 0:06 [kupdate]
root 4 0.0 0.0 0 0 ? SW 2001 0:28 [kswapd]
root 5 0.0 0.0 0 0 ? SW 2001 0:00 [keventd]
root 149 0.0 0.1 1692 120 ? S 2001 0:00 /usr/sbin/cron
root 152 0.0 0.0 2196 0 ? SW 2001 0:00 [svscanboot]
root 154 0.0 0.1 1316 104 ? S 2001 0:00 svscan /service
root 155 0.0 0.0 1268 16 ? S 2001 0:00 readproctitle service errors: ................
# pstree
runit-+-cron
|-keventd
|-kflushd
|-kswapd
|-kupdate
`-svscanboot-+-readproctitle
`-svscan-+-2*[supervise---socklog]
|-18*[supervise---multilog]
|-5*[supervise---tcpserver]
|-supervise---qmail-send-+-qmail-clean
| |-qmail-lspawn
| `-qmail-rspawn
|-supervise---sshd---sshd---bash---bash---pstree
|-supervise---bash
|-2*[supervise---getty]
|-supervise---uncat
|-supervise---dhcpd-2.2.x
|-supervise---dnscache
|-supervise---tinydns
|-supervise---isdnlog
|-supervise---sleep
|-supervise---klogd
|-2*[supervise]
|-2*[supervise---vboxgetty]
|-supervise---clockspeed
|-supervise---squid---unlinkd
`-supervise---dhclient-2.2.x
</pre>
This is from a more busy system:
<pre>
# strings /proc/1/exe |grep Id
$Id: runit.c,v 1.6 2002/01/29 18:56:36 pape Exp $
# uptime
10:44:34 up 68 days, 10:48, 3 users, load average: 0.24, 0.45, 0.34
# ps axuw |head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 24 24 ? S Feb07 0:05 runit
root 2 0.0 0.0 0 0 ? SW Feb07 0:01 [keventd]
root 3 0.0 0.0 0 0 ? SW Feb07 1:00 [kapm-idled]
root 4 0.0 0.0 0 0 ? SWN Feb07 0:44 [ksoftirqd_CPU0]
root 5 0.0 0.0 0 0 ? SW Feb07 7:02 [kswapd]
root 6 0.0 0.0 0 0 ? SW Feb07 0:00 [bdflush]
root 7 0.0 0.0 0 0 ? SW Feb07 8:06 [kupdated]
root 53 0.0 0.0 0 0 ? SW Feb07 0:00 [msp3410 [auto]]
daemon 115 0.0 0.0 1412 20 ? S Feb07 0:00 /sbin/portmap
</pre>
<hr>
See <a href="install.html">How to install runit</a> for installing
<i>runit</i> and <a href="replaceinit.html">How to replace init</a> for
smoothly escaping from <i>sysvinit</i>.
<hr>
If <i>runit</i> on linux is compiled and linked with
<a href="http://www.fefe.de/dietlibc/">dietlibc</a> it yields in a statically
linked <tt>runit</tt> binary of 14k size and this <tt>ps axuw</tt> output
on my system:
<pre>
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 24 20 ? S Nov22 0:01 runit
</pre>
I recommend doing this; for instructions, see
<a href="usedietlibc.html">How to use dietlibc</a>.
<hr>
See <a href="http://smarden.org/runit/">http://smarden.org/runit/</a>
for recent informations.
<hr>
Related links:
<ul>
<li><a href="http://www.fefe.de/minit/">minit</a>
<li><a href="http://multivac.cwru.edu/svscan-1/">svscan as process 1</a>
<li><a href="ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/">
sysvinit</a>
<li><a href="http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/init/">
OpenBSD's init</a>
<li><a href="http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/init/">
FreeBSD's init</a>
<li><a href="http://www.atnf.csiro.au/~rgooch/linux/boot-scripts/">
Richard Gooch's Linux Boot Scripts</a>
</ul>
<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape <pape@smarden.org>
</a></address>
<small>$Id$</small>
</body>
</html>
|