This commit is contained in:
2023-06-23 22:33:12 -05:00
parent 61845e5552
commit 30462b0a57
2 changed files with 12 additions and 15 deletions

View File

@@ -727,9 +727,7 @@ HAPROXY-CONFIG() {
}
SINGLE_SERVER_SERVICE_CHECK(){
if [ "${1}" = "web" ]; then
# servicestocheck=gitea,pdnsadmin
if [ "${1}" = "web" ]; then
local_ips=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | awk '/inet/ {print $2}' | cut -d'/' -f1);
# local_ips=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1);
local_ip=$(/sbin/ip -o -4 addr list eth0 |grep 255 | awk '{print $4}' | cut -d/ -f1)
@@ -739,8 +737,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
sleep 5s
fi
if [ -f /mnt/web-data/mounted ]; then
for stc in "${SINGLE_SERVICES[@]}"; do
echo "SERVICE: $stc"
for stc in "${WEB_SINGLESRVR_SERVICES[@]}"; do
if [ "$(systemctl is-active ${stc}.service)" != "active" ]; then
SENDNOTICE "Node-Balancing Notice" "Starting ${stc} on ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} (${local_ip}), stopping on the other Nodes"
echo "$(date) - ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} - Starting ${stc} on ${local_ip}, stopping on the other Nodes" >> ${LOGFILE}
@@ -755,8 +752,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
/bin/systemctl start ${stc} &
fi
done
for docker in "${SINGLE_DOCKERS[@]}"; do
echo "DOCKER: $docker"
for docker in "${WEB_SINGLESRVR_DOCKERS[@]}"; do
for nip in "${WEB_HOSTS[@]}"; do
if [[ "${local_ip}" = *"${nip}"* ]]; then
[ ! "$(/usr/bin/docker ps -q -f name=${docker})" ] && /usr/bin/docker start ${docker} & >/dev/null 2>&1
@@ -773,11 +769,11 @@ SINGLE_SERVER_SERVICE_CHECK(){
else
for stc in "${services_to_check[@]}"; do
for stc in "${WEB_SINGLESRVR_SERVICES[@]}"; do
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
/bin/systemctl stop ${stc} &
done
for docker in "${SINGLE_DOCKERS[@]}"; do
for docker in "${WEB_SINGLESRVR_DOCKERS[@]}"; do
# echo "DOCKER: $docker"
[ "$(/usr/bin/docker ps -q -f name=${docker})" ] && /usr/bin/docker stop ${docker} & >/dev/null 2>&1
# [ "$(/usr/bin/docker ps -q -f name=${docker})" ] && echo "stopping" || echo "already stopped"
@@ -785,7 +781,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
fi
if [ "$(systemctl is-active nginx)" != "active" ]; then
/usr/local/bin/nodemgmt service web restart ${local_ip}
${SCRIPT} service web restart ${local_ip}
fi
fi
}