Browse Source

check fix 2

master
gsd 6 months ago
parent
commit
8b8bcbd82c
  1. 1
      .gitignore
  2. 9
      upcheck.sh

1
.gitignore

@ -1 +1,2 @@
*.conf
*.log

9
upcheck.sh

@ -1,11 +1,13 @@
#!/bin/bash
cd "$(dirname "$0")"
LOGFILE=./upcheck.log
CONTAINER=proxywg_socks_c
PINGHOST=8.8.8.8
CHECK_CONTAINER="$(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'
docker compose up -d
exit 0
@ -20,13 +22,18 @@ do
RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')"
if [ "$RESULT" == "pass" ]; then
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "PING OK" >> $LOGFILE
exit 0
fi
echo "[" $COUNT "]" `date +%Y%m%d.%H%M%S` "PING FAIL" >> $LOGFILE
if [ $COUNT -ge 29 ]; then
echo 'container is not good'
#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
exit 0
fi
sleep 1
done

Loading…
Cancel
Save