| 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 and supervise services. By convention, a runscript for a service foo is located at /etc/sv/foo/run or at /usr/share/runit/sv.current/foo/run : runscript can be any executable file.
Debhelper addon dh_runit installs the runscript according to this convention.
To use the invoke-run interpreter, the runscript for a service foo must begin with following line:
#!/usr/bin/env /lib/runit/invoke-run
If a file /.meta/bin is found inside the foo service directory, the path inside the bin file is tested for existence and if not found on the system, the service foo is stopped. The bin file should contain only one line with the full path of the binary that is executed in the runscript.
If the init.d script /etc/init.d/foo exists, is executable and is not a symlink, it is invoked with the stop argument to gracefully replace the Sysv instance with the runit managed instance .
If the file /etc/runit/verbose exists, the message invoke-run: starting foo is printed. After that, the runscript is interpreted with /bin/sh shell and some additional environment variables are set according to the following rules:
If both /etc/default/foo file and /etc/sv/foo/env 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, defined errors and messages are:
Since version 2.1.2-48 the Debian runit package ships a /lib/runit/finish-exec file that contains code that can be shared across different services. This file can be symlinked inside the service directory, or can be exec'd like in the following example
$ cat /etc/sv/foo/finish #!/bin/sh set -e exec /lib/runit/finish-exec "$@"
Services that need to put specific code into the finish file should do before the line that exec finish-exec. Finish-exec defines special error codes as described in the previous section. If the file /etc/runit/verbose exists, a 'foo stopped' message is printed; if the file /etc/runit/debug exists, run's exit code is also printed. The finish-default shipped by previous runit package is now deprecated and scheduled removal in the near future.
| August 29, 2022 |