sysmgr

a simplistic service supervisor (deprecated)
git clone git://git.ckyln.com/~cem/sysmgr.git
Log | Files | Refs | README | LICENSE

commit 8f9003c1c2f0c1d2e4331a6f5195b9b6347e116d
parent f7a65ab11c21dfd114e46458cf0d40b618dcc2bd
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue,  7 Jul 2020 15:46:13 +0300

docs: update

Diffstat:
Mdocs/service-scripts.txt | 40+++++++++++++++++++++++++++++++++++++---
Msysmgr | 2+-
2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/docs/service-scripts.txt b/docs/service-scripts.txt @@ -1,4 +1,13 @@ -Creating Service Scripts +SERVICE SCRIPTS +-------------------------------------------------------------------------------- + +TABLE OF CONTENTS +- Creating service scripts [1.0] + - Service dependencies [1.1] + - Running commands after service stop [1.2] + + +[1.0] Creating service scripts -------------------------------------------------------------------------------- Service scripts can be anything from C binaries to shell scripts. All they need @@ -26,7 +35,7 @@ Another thing you may have noticed is the 'exec' part of the service. In shell, This is also necessary to track the correct process. -Service dependencies +[1.1] Service dependencies -------------------------------------------------------------------------------- Some services may depend on other services in order to start working. An example @@ -47,7 +56,32 @@ dependencies. Here are example service scripts for NetworkManager and dbus. +--------------------------------------------------------------------------+ | | | #!/bin/sh | - | sysmgr-needs dbus | + | sysmgr-needs dbus || exit 1 | | exec NetworkManager -n | | | +--------------------------------------------------------------------------+ + + +[1.2] Running commands after service stop +-------------------------------------------------------------------------------- + +sysmgr doesn't come with a way to handling service stops. Runit has the 'stop' +script and systemd comes with a 'ExecStop' command. This can be easily handled +within the service script itself. + + +--------------------------------------------------------------------------+ + | /etc/sysmgr/agetty-1 | + +--------------------------------------------------------------------------+ + | | + | #!/bin/sh | + | setsid agetty tty1 38400 linux & | + | | + | # Get the process id and replace the stored process id with agetty's | + | printf '%s\n' "$!" > /run/sysmgr/agetty-1/pid | + | wait | + | | + | # Wait until agetty dies and continue the script | + | utmpset -w tty1 | + | | + +--------------------------------------------------------------------------+ + diff --git a/sysmgr b/sysmgr @@ -176,7 +176,7 @@ fn_runsyssv() { trap "redirectsignal $sig" $sig done - # Wait until service goes down + # Wait until service goes down. wait # Do a cleanup when the service is killed.