INVOKE-RUN(8) | GNU/Linux System Adminstrator's manual | INVOKE-RUN(8) |
invoke-run - runscript interpreter
/usr/bin/env /lib/run/invoke-run
The runit supervision system uses scripts, called runscripts to start services. By convention, runscript for a service foo is located at /etc/sv/foo/run
Debhelper addon dh_runit installs runscript according this convention.
Runscript can be any executable file. Runscript can use invoke-run interpreter only if it is installed according convention,
To use invoke-run interpreter, runscript /etc/sv/foo/run for service foo must begin with following line:
#!/usr/bin/env /lib/runit/invoke-run
If init.d script /etc/init.d/foo exists, it is invoked with stop argument to gracefully handle package upgrade to version, introducing runscript. After that, /bin/sh shell interpret rest of runscript, with some additional environment set according following rules:
If both /etc/default/foo file and /etc/sv/foo/conf directory define some variable, value from directory takes precedence.
Looking in the foo service log it's possible to see messages in the form of
These messages don't come from runsv itself but from invoke-run, the run file or the finish file. The purpose of these message is to detail a permanent failure condition that prevents foo service from being up. For each foo service, possible errors and messages are:
Since version 2.1.2-36 the Debian runit package ships a /lib/runit/finish-default file that contains code that can be shared across different services. This file can be sourced inside the regular finish file of a service, like the following example
$ cat /etc/sv/foo/finish
#!/bin/sh
set -e . /lib/runit/finish-default "$@"
Services that need to put specific code into the finish file should do after the line that sources finish-default. For each foo service, finish-default file sources /etc/default/runit, export a NAME=foo variable and defines special error codes as described in the previous section. Also, when VERBOSE mode is on, EXIT is trapped so that a 'foo stopped' message gets printed at the very end of the finish file.
January 21, 2019 |