Line 25: |
Line 25: |
| * restarts the process if it fails | | * restarts the process if it fails |
| * provides a consistent mechanism for controlling the underlying process | | * provides a consistent mechanism for controlling the underlying process |
− | | + | {{Note box|msg=Gerrit Pape's '''runit''' came from previous work by Dan Bernstein on the '''supervise''' supervision environment. '''runit''' provides additional features, and has been released under a free software license.}} |
− | <div class="NOTE"><blockquote class="NOTE">
| + | <div class="SECT2"> |
− | | |
− | '''Note: '''Gerrit Pape's '''runit''' came from previous work by Dan Bernstein on the '''supervise''' supervision environment. '''runit''' provides additional features, and has been released under a free software license.
| |
− | | |
− | </blockquote></div><div class="SECT2">
| |
| ---- | | ---- |
| | | |
Line 74: |
Line 70: |
| | | |
| This looks like a complex process tree, but is a critical part of the SME Server's design for reliability. Each process is independent, has a consistent management interface, has process limits imposed on it, and will restart if it happens to fail. | | This looks like a complex process tree, but is a critical part of the SME Server's design for reliability. Each process is independent, has a consistent management interface, has process limits imposed on it, and will restart if it happens to fail. |
− | | + | {{Note box|msg=For the curious, if init fails, the system reboots.}} |
− | <div class="NOTE"><blockquote class="NOTE">
| |
− | | |
− | '''Note: '''For the curious, if init fails, the system reboots.
| |
− | | |
− | </blockquote></div>
| |
| | | |
| For further documentation on runit, refer to the runit manual page. | | For further documentation on runit, refer to the runit manual page. |
Line 110: |
Line 101: |
| * If so, it runs the <tt class="FILENAME">/etc/init.d/syslog</tt> script with the argument <var class="LITERAL">start</var>. | | * If so, it runs the <tt class="FILENAME">/etc/init.d/syslog</tt> script with the argument <var class="LITERAL">start</var>. |
| * If the service is not enabled, it exits without starting the service. | | * If the service is not enabled, it exits without starting the service. |
| + | {{Note box|msg=If a script exists in the <tt class="FILENAME">/etc/init.d/supervise/</tt> directory, <tt class="FILENAME">e-smith-service</tt> will use that in preference to the one in the <tt class="FILENAME">/etc/init.d/</tt> directory. This allows us to install our own supervised startup scripts <span class="emphasis">''without modifying the original package''</span>.}} |
| + | |
| + | ===Adding a supervised service=== |
| + | See http://cr.yp.to/daemontools.html |
| + | |
| + | Check your application has a -d option or similar which means that it stays in the foreground, and logs to standard output rather than syslog. That makes it suitable for running as a supervised service. |
| + | |
| + | Create a /var/service/XXX directory, containing an executable 'run' script something like: |
| + | |
| + | #! /bin/sh |
| + | exec 2>&1 |
| + | exec /var/service/XXX -d |
| + | |
| + | and a /var/service/XXX/log directory, containing an executable 'run' script something like: |
| + | |
| + | #! /bin/sh |
| + | exec setuidgid smelog \ |
| + | /usr/local/bin/multilog t s500000 \ |
| + | /var/log/XXX |
| | | |
− | <div class="NOTE"><blockquote class="NOTE">
| + | You would then do: |
| | | |
− | '''Note: '''If a script exists in the <tt class="FILENAME">/etc/init.d/supervise/</tt> directory, <tt class="FILENAME">e-smith-service</tt> will use that in preference to the one in the <tt class="FILENAME">/etc/init.d/</tt> directory. This allows us to install our own supervised startup scripts <span class="emphasis">''without modifying the original package''</span>.
| + | mkdir /var/log/XXX |
| + | chown smelog.smelog /var/log/XXX |
| + | ln -s /var/service/XXX /service |
| + | touch /var/service/XXX/down |
| | | |
− | </blockquote></div></div></div></div>
| + | </div></div></div> |