49 lines
868 B
Bash
49 lines
868 B
Bash
#!/bin/sh
|
|
# runit library
|
|
svall () {
|
|
|
|
for _srv in $(basename -a $(ls -d1 $SVDIR/*/)); do
|
|
if [ -z "$1" ]; then
|
|
echo $_srv
|
|
else
|
|
echo $1 for $_srv
|
|
sv $1 $_srv
|
|
fi
|
|
done
|
|
|
|
}
|
|
|
|
shutdown() {
|
|
# first shutdown any service started by runit
|
|
|
|
echo first shutting down all services
|
|
svall force-stop
|
|
# shutdown RUNIT command
|
|
RUNIT=${RUNIT:-$(cat ${SVDIR:-/opt/services}/pid)}
|
|
echo now killing runit at pid $RUNIT
|
|
kill -HUP $RUNIT
|
|
echo runit is shutdown
|
|
|
|
}
|
|
|
|
|
|
startup () {
|
|
|
|
[ -z $SVDIR ] && echo using default services directory /opt/services
|
|
SVDIR=${SVDIR:-/opt/services}
|
|
export SVDIR=${1:-$SVDIR}
|
|
echo starting up services in $SVDIR
|
|
exec runsvdir -P ${1:-$SVDIR} &
|
|
|
|
RUNIT=$!
|
|
echo $RUNIT > $SVDIR/pid
|
|
export RUNIT
|
|
echo
|
|
echo "Started services at $SVDIR, PID is $RUNIT"
|
|
echo "waiting for service processes to start...."
|
|
sleep 3
|
|
svall status
|
|
|
|
}
|
|
|