sysmgr

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

commit e74a213e9c64b65cc76c141cad503f76536dfe1a
parent 5828e0f32dd258ed5584cf7c3a8e2387bf5ce6b7
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon, 23 Mar 2020 23:44:10 +0300

sysmgr-needs: add utility to repository

Diffstat:
Autils/sysmgr-needs | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/utils/sysmgr-needs b/utils/sysmgr-needs @@ -0,0 +1,29 @@ +#!/bin/sh + +# A simple utility for dependency tracking with sysmgr. + +[ "$1" ] || { cat <<EOF +usage: ${0##*/} [dep1] [dep2] [dep...] + +sysmgr utility for service dependency tracking. +This program waits until all dependencies are +started with sysmgr. +EOF + exit 1 ;} + +checkprocess() { + # This is quite similar to the function with the + # same name on sysmgr, except it gets the pid itself. + read -r pid < "$RUNDIR/$1/pid" + [ -d /proc ] || { + kill -0 "$pid" || return 1 + return 0 + } + [ -d "/proc/$pid" ] || return 1 + return 0 +} + +for service in "$@" ; do + # We parallelize and wait for all checks to pass. + while :; do [ -r "${RUNDIR:=/run/sysmgr}/${service}/pid" ] && checkprocess "$service" && break ; done & +done; wait