Update services.inc

This commit is contained in:
2023-07-06 22:32:09 -05:00
parent 0b586f400e
commit 019448eda7

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env bash
SINGLE_SERVER_SERVICE_CHECK(){
servicestocheck=${1^^}_SINGLESRVR_SERVICES[@]
dockerstocheck=${1^^}_SINGLESRVR_DOCKERS[@]
@@ -8,6 +9,10 @@ SINGLE_SERVER_SERVICE_CHECK(){
local_ips=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | awk '/inet/ {print $2}' | cut -d'/' -f1);
local_ip=$(/sbin/ip -o -4 addr list eth0 |grep 255 | awk '{print $4}' | cut -d/ -f1)
if [[ ${local_ips} = *10.10.1.120* ]]; then
if [ ! -f ${NM_TMPFOLDER}/.singleserver ]; then
SENDNOTICE "Node-Balancing Notice" "Starting SingleServer Services on ${NM_NODETYPES["WEB"]}-Node${local_ip: -1} (${local_ip}), stopping on other Nodes"
touch ${NM_TMPFOLDER}/.singleserver
fi
if [ ! -f /mnt/web-data/mounted ]; then
/bin/mount -a
sleep 5s
@@ -15,13 +20,13 @@ SINGLE_SERVER_SERVICE_CHECK(){
if [ -f ${NM_REPL_CHECK_LOC["${1}-data"]}/mounted ]; then
for stc in "${!servicestocheck}"; 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" >> ${NM_LOGFILE}
[ "${stc}" = "pdnsadmin" ] && stc="pdnsadmin.socket pdnsadmin.service"
for nip in "${!hosts}"; do
if [[ "${local_ip}" != *"${nip}"* ]]; then
ssh root@${nip} /bin/systemctl stop ${stc}
ssh -tq root@${nip} /bin/systemctl stop ${stc}
ssh -tq root@${nip} rm -f ${NM_TMPFOLDER}/.singleserver
fi
done
sleep 3s