Many validating fixes.

This commit is contained in:
2021-06-13 09:22:53 +00:00
parent 8ad06e2681
commit 7efbed41f4

View File

@@ -17,22 +17,19 @@ service_exec="docker run --rm -v /etc/user/config/services/:/services/:ro -v /va
SERVICE_NAME="public-proxy" SERVICE_NAME="public-proxy"
do_proxy_restart() { do_proxy_restart() {
for proxies in $CONTAINER_NAMES ; do
local NAMES="$1"
for proxies in $NAMES ; do
docker stop $proxies; docker stop $proxies;
sleep $TIMEOUT; sleep $TIMEOUT;
#$service_exec $SERVICE_NAME.containers.$proxies start #$service_exec $SERVICE_NAME.containers.$proxies start
if docker ps | grep $proxies ; then if docker ps | grep $proxies ; then
echo "$proxies restarted successful"; echo "$proxies restarted successful";
else else
RESTART_COUNTER=0
PROXY_NAME=$proxies PROXY_NAME=$proxies
for retries in $(seq 0 $RESTART); do for retries in $(seq 0 $((RESTART + 1))); do
RESTART_COUNTER=$((RESTART_COUNTER +1)) if [[ $retries -le $RESTART ]] ; then
echo "Retried number is: "$retries;
echo "restart_value is: "$RESTART;
echo "restart counter is: "$RESTART_COUNTER;
echo "proxy name: "$PROXY_NAME;
if [[ $RESTART -le $retries ]] ; then
echo "Proxy "$PROXY_NAME" restarting in progress"; echo "Proxy "$PROXY_NAME" restarting in progress";
#$service_exec $SERVICE_NAME.containers.$PROXY_NAME start #$service_exec $SERVICE_NAME.containers.$PROXY_NAME start
if docker ps | grep $PROXY_NAME ; then if docker ps | grep $PROXY_NAME ; then
@@ -48,7 +45,7 @@ for proxies in $CONTAINER_NAMES ; do
fi fi
done done
fi fi
done done
} }
check_domain() { echo "Checking $DOMAIN name" check_domain() { echo "Checking $DOMAIN name"
@@ -85,7 +82,7 @@ done;
# The roles numbers and the running containers numbers are equal or greater than 2 # The roles numbers and the running containers numbers are equal or greater than 2
if [[ "$RUNNING_CONTAINERS" == "$CONTAINERS_BY_ROLE" || "$RUNNING_CONTAINERS" -ge 2 ]] ; then if [[ "$RUNNING_CONTAINERS" == "$CONTAINERS_BY_ROLE" || "$RUNNING_CONTAINERS" -ge 2 ]] ; then
echo "Starting proxy restart process"; echo "Starting proxy restart process";
do_proxy_restart ; do_proxy_restart "$CONTAINER_NAMES";
# In case of no running proxies found, try to start the service # In case of no running proxies found, try to start the service
elif [[ "$RUNNING_CONTAINERS" -eq 0 ]] ; then elif [[ "$RUNNING_CONTAINERS" -eq 0 ]] ; then
@@ -123,7 +120,7 @@ for CHECK_PROXIES in $CONTAINERS ; do
if [[ $CHECK_PROXIES != $ONLY_RUNNING_PROXY_NAME ]] ; then if [[ $CHECK_PROXIES != $ONLY_RUNNING_PROXY_NAME ]] ; then
if docker ps | grep $CHECK_PROXIES ; then if docker ps | grep $CHECK_PROXIES ; then
echo "Not running proxies successfuly started, let's start the only running one."; echo "Not running proxies successfuly started, let's start the only running one.";
#do_proxy_restart $ONLY_RUNNING_PROXY_NAME; do_proxy_restart $ONLY_RUNNING_PROXY_NAME;
else else
echo "Not enough running proxies found, can't start the only running one."; echo "Not enough running proxies found, can't start the only running one.";
fi fi