Add restart option to create-cluster script (#12885)

When testing and debugging the cluster code before, you need
to stop the cluster after making changes, and then start the
cluster again. Add a restart option for ease of use.
This commit is contained in:
Binbin 2023-12-26 10:36:44 +08:00 committed by GitHub
parent 20214b26a4
commit 71f31da66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,6 +58,23 @@ then
exit 0 exit 0
fi fi
if [ "$1" == "restart" ]
then
OLD_PORT=$PORT
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
$BIN_PATH/redis-cli -p $PORT shutdown nosave
done
PORT=$OLD_PORT
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
$BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
done
exit 0
fi
if [ "$1" == "watch" ] if [ "$1" == "watch" ]
then then
PORT=$((PORT+1)) PORT=$((PORT+1))
@ -113,10 +130,11 @@ then
exit 0 exit 0
fi fi
echo "Usage: $0 [start|create|stop|watch|tail|tailall|clean|clean-logs|call]" echo "Usage: $0 [start|create|stop|restart|watch|tail|tailall|clean|clean-logs|call]"
echo "start -- Launch Redis Cluster instances." echo "start -- Launch Redis Cluster instances."
echo "create [-f] -- Create a cluster using redis-cli --cluster create." echo "create [-f] -- Create a cluster using redis-cli --cluster create."
echo "stop -- Stop Redis Cluster instances." echo "stop -- Stop Redis Cluster instances."
echo "restart -- Restart Redis Cluster instances."
echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node." echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
echo "tail <id> -- Run tail -f of instance at base port + ID." echo "tail <id> -- Run tail -f of instance at base port + ID."
echo "tailall -- Run tail -f for all the log files at once." echo "tailall -- Run tail -f for all the log files at once."