aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/respawn-only.sh
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-16 00:24:24 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-16 14:15:50 +0100
commite45fc8635926f70b0e19d5214f1f8b8fd06068aa (patch)
treec8623507ffc51331484e4ed8b9c4478acb34d09b /contrib/respawn-only.sh
parent54dd949e623d2f9535e30d450c198d15e5e98e91 (diff)
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.
Diffstat (limited to 'contrib/respawn-only.sh')
-rwxr-xr-xcontrib/respawn-only.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/respawn-only.sh b/contrib/respawn-only.sh
index 4f611dd2..66aaac79 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