This commit is contained in:
2023-06-23 22:22:26 -05:00
parent 9c384b6d6a
commit 61845e5552
2 changed files with 12 additions and 8 deletions

View File

@@ -729,9 +729,6 @@ HAPROXY-CONFIG() {
SINGLE_SERVER_SERVICE_CHECK(){
if [ "${1}" = "web" ]; then
# servicestocheck=gitea,pdnsadmin
servicestocheck=gitea
dockerstocheck=( heimdall vaultwarden authelia )
IFS=,; services_to_check=(${servicestocheck}); unset IFS
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);
@@ -742,7 +739,8 @@ SINGLE_SERVER_SERVICE_CHECK(){
sleep 5s
fi
if [ -f /mnt/web-data/mounted ]; then
for stc in "${services_to_check[@]}"; do
for stc in "${SINGLE_SERVICES[@]}"; do
echo "SERVICE: $stc"
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}
@@ -757,8 +755,8 @@ SINGLE_SERVER_SERVICE_CHECK(){
/bin/systemctl start ${stc} &
fi
done
for docker in "${dockerstocheck[@]}"; do
# echo "DOCKER: $docker"
for docker in "${SINGLE_DOCKERS[@]}"; do
echo "DOCKER: $docker"
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
@@ -779,7 +777,7 @@ SINGLE_SERVER_SERVICE_CHECK(){
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
/bin/systemctl stop ${stc} &
done
for docker in "${dockerstocheck[@]}"; do
for docker in "${SINGLE_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"