From e45fc8635926f70b0e19d5214f1f8b8fd06068aa Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 16 Mar 2013 00:24:24 +0100 Subject: [PATCH] respawn: Adjust the oom score for the supervisor and bts/pcu, increase sleep Make the script mostly unkillable due to OOM and make sure that the process has a score of zero. Wait 10 seconds before re-launching. The combination of ( && exec ) & appears to save one sub-process. The script has been tested with bash and busybox's ash. --- contrib/respawn-only.sh | 10 +++++++++- contrib/respawn.sh | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/contrib/respawn-only.sh b/contrib/respawn-only.sh index 4f611dd2a..66aaac79d 100755 --- a/contrib/respawn-only.sh +++ b/contrib/respawn-only.sh @@ -1,4 +1,12 @@ #!/bin/sh + +PID=$$ +echo "-1000" > /proc/$PID/oom_score_adj + + while [ -f $1 ]; do - nice -n -20 $* + (echo "0" > /proc/self/oom_score_adj && exec nice -n -20 $*) & + LAST_PID=$! + wait $LAST_PID + sleep 10s done diff --git a/contrib/respawn.sh b/contrib/respawn.sh index 0798a47a9..44e4fdc3c 100755 --- a/contrib/respawn.sh +++ b/contrib/respawn.sh @@ -1,6 +1,16 @@ #!/bin/sh + +PID=$$ +echo "-1000" > /proc/$PID/oom_score_adj + while [ -e /etc/passwd ]; do + cat /lib/firmware/sysmobts-v?.bit > /dev/fpgadl_par0 + sleep 2s cat /lib/firmware/sysmobts-v?.out > /dev/dspdl_dm644x_0 + sleep 1s echo "0" > /sys/class/leds/activity_led/brightness - nice -n -20 $* + (echo "0" > /proc/self/oom_score_adj && exec nice -n -20 $*) & + LAST_PID=$! + wait $LAST_PID + sleep 10s done