osmo-service-respawn: Add a shell script that spawns and respawns services
Adjust the oom_score_adj of the shell script to avoid ever beeing killed. Adjust the score of the child and nice it. Sleep a given interval before respawning it. This script creates a .pid file so it can be used by a sysv init script to stop the respawner and the client.
This commit is contained in:
parent
85d5ea4aae
commit
1b7bb4ae95
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
NAME=`basename $1`
|
||||
PIDFILE="/var/run/$NAME.pid"
|
||||
PID=$$
|
||||
echo "$PID" > $PIDFILE
|
||||
echo "-1000" > /proc/$PID/oom_score_adj
|
||||
|
||||
trap "{ rm -f $PIDFILE ; kill 0; }" EXIT
|
||||
|
||||
while true;
|
||||
do
|
||||
echo "Restarting not dealing well with spaces.."
|
||||
(echo "0" > /proc/self/oom_score_adj && exec $@) &
|
||||
LAST_PID=$!
|
||||
wait $LAST_PID
|
||||
sleep 10s
|
||||
done
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
DESCRIPTION = "Shell script to start, nice and respawn services"
|
||||
HOMEPAGE = "http://openbsc.osmocom.org/"
|
||||
LICENSE = "AGPLv3+"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
|
||||
|
||||
SRC_URI = "file://osmo-service-respawn.sh"
|
||||
|
||||
RDEPENDS_${PN} = "bash"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0775 ${WORKDIR}/osmo-service-respawn.sh ${D}${bindir}
|
||||
}
|
Loading…
Reference in New Issue