feat(node): try to manage scale up and scale down

This commit is contained in:
2025-05-27 15:26:28 +02:00
parent d655d0449f
commit 004cd98224
8 changed files with 71 additions and 41 deletions

View File

@ -1,14 +1,12 @@
#!/bin/sh
PATH=${PATH}:/
SENTINEL_MASTER=""
# Generate sentinel.conf file for Valkey Sentinel
source /opt/scripts/common.sh
if [ -f /etc/valkey/sentinel.conf ]; then
echo "Sentinel configuration file already exists, starting with this."
else
PATH=${PATH}:/
SENTINEL_MASTER=""
updateSentinelMaster(){
cp /etc/valkey/sentinel.conf.orig /etc/valkey/sentinel.conf
hostname=$(hostname -f)
@ -16,11 +14,25 @@ else
if [ $? -ne 0 ]; then
SENTINEL_MASTER=$(hostname -f)
else
getPrimaryInfo
SENTINEL_MASTER=$(getSentinelMasterName)
fi
sed -i "s/SENTINEL_MASTER/${SENTINEL_MASTER}/g" /etc/valkey/sentinel.conf
}
if [ -f /etc/valkey/sentinel.conf ]; then
echo "Sentinel configuration file already exists, starting with this."
reps=$(awk -F ':' '/REPLICAS/ {print $2}' /etc/valkey/sentinel.conf)
if [ "${reps}" = "${VALKEY_REPLICAS}" ]; then
echo "Sentinel configuration file already has the correct number of replicas (${VALKEY_REPLICAS})."
else
echo "Updating Sentinel configuration file with the correct number of replicas (${VALKEY_REPLICAS})."
updateSentinelMaster
fi
else
updateSentinelMaster
fi
valkey-sentinel /etc/valkey/sentinel.conf