Holger Hans Peter Freyther | 1b7bb4a | 2013-03-16 11:25:49 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
2 | |||||
3 | NAME=`basename $1` | ||||
4 | PIDFILE="/var/run/$NAME.pid" | ||||
5 | PID=$$ | ||||
6 | echo "$PID" > $PIDFILE | ||||
7 | echo "-1000" > /proc/$PID/oom_score_adj | ||||
8 | |||||
9 | trap "{ rm -f $PIDFILE ; kill 0; }" EXIT | ||||
10 | |||||
11 | while true; | ||||
12 | do | ||||
13 | echo "Restarting not dealing well with spaces.." | ||||
14 | (echo "0" > /proc/self/oom_score_adj && exec $@) & | ||||
15 | LAST_PID=$! | ||||
16 | wait $LAST_PID | ||||
17 | sleep 10s | ||||
18 | done | ||||
19 |