33 lines
588 B
Bash
Executable file
33 lines
588 B
Bash
Executable file
#!/bin/sh
|
|
. bin/lilarc
|
|
|
|
if [ $1 = "ai" ]; then
|
|
URL="http://localhost:9000/ai/stockfish/play"
|
|
else
|
|
URL=$AI_PROD_URL
|
|
fi
|
|
|
|
TIMEOUT=10 # 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
|
|
|
|
code=$(curl $URL --max-time $TIMEOUT -sL -w "%{http_code}" -o /dev/null)
|
|
|
|
if [[ $? != 0 ]]; then
|
|
lilalog "FAIL $MSG"
|
|
service lila restart
|
|
elif [[ $code != 200 ]]; then
|
|
lilalog "CODE $code"
|
|
service lila restart
|
|
else
|
|
echo -n "."
|
|
fi
|
|
|
|
done
|