| Server IP : 193.86.120.172 / Your IP : 216.73.216.67 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/packages/SynologyApplicationService/scripts/ |
Upload File : |
#!/bin/sh
. /var/packages/SynologyApplicationService/scripts/utils
if ! FSDNIsSupported; then
exit 0
fi
admin_node_name=$(/usr/syno/bin/aacore who-is-admin-node)
remote_ip=$(/usr/syno/bin/aacore get-ntb-addr remote)
. /var/packages/SynologyApplicationService/target/etc/valkey_admin_pass.env
ROLE_FILE=/var/packages/SynologyApplicationService/tmp/valkey_start_as_role
VALKEY_SOCK=/var/run/SynologyApplicationService/valkey.sock
VALKEY_LOCAL_CLI="/var/packages/SynologyApplicationService/target/usr/bin/valkey-cli --user admin -s $VALKEY_SOCK"
VALKEY_REMOTE_CLI="/var/packages/SynologyApplicationService/target/usr/bin/valkey-cli --user admin -h $remote_ip -p 29000"
if [ "$SYNOPKG_PKG_ROLLING_UPGRADE" = "yes" ] ; then
# Only when it is non-admin node and admin node is upgrading
if ! FSDNIsAdminNode && [ "${WORKLOAD}" = $admin_node_name ]; then
if [ "${ACTION}" = "takeover" ]; then
synosystemctl start pkg-SynologyApplicationService-notification_send "test -S /var/run/notification_send.sock"
if (( $? != 0 )); then
echo "Failed to start service [notification send]"
fi
synosystemctl start pkg-SynologyApplicationService-VapidSendServer "test -S /var/run/vapid_send_server.sock"
if (( $? != 0 )); then
echo "Failed to start service [vapid send server]"
fi
# This makes haproxy start as replica even on admin node
echo "primary" > $ROLE_FILE
synosystemctl restart pkg-SynologyApplicationService-haproxy
rm -f $ROLE_FILE
$VALKEY_LOCAL_CLI REPLICAOF NO ONE
elif [ "${ACTION}" = "giveback" ]; then
synosystemctl stop pkg-SynologyApplicationService-notification_send
synosystemctl stop pkg-SynologyApplicationService-VapidSendServer
# We don't stop haproxy and valkey here because replication to admin node might still be happening
fi
fi
if FSDNIsAdminNode && [ "${WORKLOAD}" = $admin_node_name ]; then
if [ "${ACTION}" = "takeover" ]; then
$VALKEY_LOCAL_CLI REPLICAOF $remote_ip 29000
while true; do
repl_info=$($VALKEY_LOCAL_CLI INFO replication)
sync_progress=$(echo "$repl_info" | grep "^master_sync_in_progress" | cut -d':' -f2 | tr -d '\r')
master_link_status=$(echo "$repl_info" | grep "^master_link_status" | cut -d':' -f2 | tr -d '\r')
slave_repl_offset=$(echo "$repl_info" | grep "^slave_repl_offset" | cut -d':' -f2 | tr -d '\r')
remote_repl_info=$($VALKEY_REMOTE_CLI INFO replication)
master_repl_offset=$(echo "$remote_repl_info" | grep "^master_repl_offset" | cut -d':' -f2 | tr -d '\r')
echo "Sync progress: $sync_progress, Master offset: $master_repl_offset, Slave Offset: $slave_repl_offset, link status: $master_link_status"
if [ "$master_link_status" == "up" ] && [ "$sync_progress" == "0" ] && [ "$master_repl_offset" == "$slave_repl_offset" ]; then
echo "Replication complete for rolling upgrade"
break
else
sleep 1
fi
done
$VALKEY_LOCAL_CLI REPLICAOF NO ONE
fi
fi
fi
# It is a promote if not rolling upgrading. SAS uses promote/standby hooks to rebalance.
exit 0