implement timeout restarter script

This commit is contained in:
Thibault Duplessis 2012-08-01 23:01:48 +02:00
parent b6969f8d22
commit adea80a11b

24
bin/prod/timeout-restarter Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
source bin/lilarc
URL=$PROD_URL
TIMEOUT=5 # Restart if it takes longer than that
DELAY=20 # Check every delay
MSG="Connect to $URL in less than $TIMEOUT seconds"
lilalog "Start timeout restarter"
while true; do
sleep $DELAY
curl $URL --max-time $TIMEOUT -so /dev/null
if [ $? = 0 ]; then
lilalog "SUCCESS $MSG"
else
lilalog "FAIL $MSG"
bin/prod/restart
fi
done