|
|
@ -5,7 +5,7 @@ LOGFILE=./upcheck.log |
|
|
|
CONTAINER=proxywg_socks_c |
|
|
|
PINGHOST=8.8.8.8 |
|
|
|
|
|
|
|
CHECK_CONTAINER="$(docker ps | grep $CONTAINER | wc -l)" |
|
|
|
CHECK_CONTAINER="$(/usr/bin/docker ps | grep $CONTAINER | wc -l)" |
|
|
|
if [ "$CHECK_CONTAINER" == "0" ]; then |
|
|
|
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "CONTAINER FAIL" >> $LOGFILE |
|
|
|
echo 'container is not started' |
|
|
@ -19,21 +19,25 @@ MAXPING=30 |
|
|
|
while [ $COUNT -le $MAXPING ] |
|
|
|
do |
|
|
|
COUNT=`expr $COUNT + 1` |
|
|
|
RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')" |
|
|
|
/usr/bin/docker exec -it $CONTAINER /bin/sh -c 'ping -c 1 -W 1 '$PINGHOST' > /dev/null && exit 0 || exit 1' |
|
|
|
|
|
|
|
if [ "$RESULT" == "pass" ]; then |
|
|
|
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "PING OK" >> $LOGFILE |
|
|
|
if [ $? == 0 ]; then |
|
|
|
echo "["$COUNT"]" `date +%Y%m%d.%H%M%S` $? >> $LOGFILE |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
|
|
|
|
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "PING FAIL" >> $LOGFILE |
|
|
|
if [ $? == 1 ]; then |
|
|
|
echo "["$COUNT"]" `date +%Y%m%d.%H%M%S` $? >> $LOGFILE |
|
|
|
|
|
|
|
if [ $COUNT -ge 29 ]; then |
|
|
|
#echo 'container is not good' |
|
|
|
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "PING FAIL TOTALY" >> $LOGFILE |
|
|
|
docker compose down |
|
|
|
docker compose up -d |
|
|
|
if [ $COUNT -ge 29 ]; then |
|
|
|
echo "["$COUNT"]" `date +%Y%m%d.%H%M%S` "PING FAIL TOTALY" >> $LOGFILE |
|
|
|
docker compose down |
|
|
|
docker compose up -d |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
sleep 1 |
|
|
|
else |
|
|
|
echo "["$COUNT"]" `date +%Y%m%d.%H%M%S` $? >> $LOGFILE |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
sleep 1 |
|
|
|
done |
|
|
|