futriix/cluster-experimental
Григорий Сафронов 5b4ca543a2
Some checks failed
External Server Tests / test-external-nodebug (push) Has been cancelled
Spellcheck / Spellcheck (push) Has been cancelled
CI / build-32bit (push) Has been cancelled
CI / build-libc-malloc (push) Has been cancelled
CI / build-almalinux8-jemalloc (push) Has been cancelled
Clang Format Check / clang-format-check (push) Has been cancelled
Codecov / code-coverage (push) Has been cancelled
External Server Tests / test-external-standalone (push) Has been cancelled
External Server Tests / test-external-cluster (push) Has been cancelled
CI / test-ubuntu-latest (push) Has been cancelled
CI / test-ubuntu-latest-cmake (push) Has been cancelled
CI / test-sanitizer-address (push) Has been cancelled
CI / test-rdma (push) Has been cancelled
CI / build-debian-old (push) Has been cancelled
CI / build-macos-latest (push) Has been cancelled
CI / format-yaml (push) Has been cancelled
Daily / test-ubuntu-jemalloc (push) Has been cancelled
Daily / test-ubuntu-jemalloc-fortify (push) Has been cancelled
Daily / test-ubuntu-libc-malloc (push) Has been cancelled
Daily / test-ubuntu-no-malloc-usable-size (push) Has been cancelled
Daily / test-ubuntu-32bit (push) Has been cancelled
Daily / test-ubuntu-tls (push) Has been cancelled
Daily / test-ubuntu-tls-no-tls (push) Has been cancelled
Daily / test-ubuntu-io-threads (push) Has been cancelled
Daily / test-ubuntu-tls-io-threads (push) Has been cancelled
Daily / test-ubuntu-reclaim-cache (push) Has been cancelled
Daily / test-valgrind-test (push) Has been cancelled
Daily / test-valgrind-misc (push) Has been cancelled
Daily / test-valgrind-no-malloc-usable-size-test (push) Has been cancelled
Daily / test-valgrind-no-malloc-usable-size-misc (push) Has been cancelled
Daily / test-sanitizer-address (clang) (push) Has been cancelled
Daily / test-sanitizer-address (gcc) (push) Has been cancelled
Daily / test-sanitizer-undefined (clang) (push) Has been cancelled
Daily / test-sanitizer-undefined (gcc) (push) Has been cancelled
Daily / test-sanitizer-force-defrag (push) Has been cancelled
Daily / test-almalinux8-jemalloc (push) Has been cancelled
Daily / test-almalinux9-jemalloc (push) Has been cancelled
Daily / test-fedoralatest-jemalloc (push) Has been cancelled
Daily / test-fedorarawhide-jemalloc (push) Has been cancelled
Daily / test-centosstream9-jemalloc (push) Has been cancelled
Daily / test-almalinux8-tls-module (push) Has been cancelled
Daily / test-almalinux9-tls-module (push) Has been cancelled
Daily / test-fedoralatest-tls-module (push) Has been cancelled
Daily / test-fedorarawhide-tls-module (push) Has been cancelled
Daily / test-centosstream9-tls-module (push) Has been cancelled
Daily / test-almalinux8-tls-module-no-tls (push) Has been cancelled
Daily / test-almalinux9-tls-module-no-tls (push) Has been cancelled
Daily / test-fedoralatest-tls-module-no-tls (push) Has been cancelled
Daily / test-fedorarawhide-tls-module-no-tls (push) Has been cancelled
Daily / test-centosstream9-tls-module-no-tls (push) Has been cancelled
Daily / test-macos-latest (push) Has been cancelled
Daily / test-macos-latest-sentinel (push) Has been cancelled
Daily / test-macos-latest-cluster (push) Has been cancelled
Daily / build-macos (macos-13) (push) Has been cancelled
Daily / build-macos (macos-14) (push) Has been cancelled
Daily / test-freebsd (push) Has been cancelled
Daily / test-alpine-jemalloc (push) Has been cancelled
Daily / test-alpine-libc-malloc (push) Has been cancelled
Daily / reply-schemas-validator (push) Has been cancelled
Daily / notify-about-job-results (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
Update cluster-experimental
2025-04-04 19:40:14 +00:00

193 lines
5.0 KiB
Bash

#!/usr/bin/env sh
# This script automatically picked and started Futriix-cluster
# Also in this script added color indicator "Ok" and "Fail"
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Settings of color
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_NORMAL="echo -en \\033[0;39m"
# Settings
BIN_PATH="$SCRIPT_DIR/src"
CLUSTER_HOST=127.0.0.1
PORT=7000
TIMEOUT=2000
NODES=6
REPLICAS=1
PROTECTED_MODE=yes
ADDITIONAL_OPTIONS=""
CONFIG_PATH="./futriix.conf"
# You may want to put the above config parameters into config.sh in order to
# override the defaults without modifying this script.
if [ -a config.sh ]
then
source "config.sh"
fi
# Computed vars
ENDPORT=$((PORT+NODES))
#if [ $? -eq 0 ]; then
# $SETCOLOR_SUCCESS
# echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]"
# $SETCOLOR_NORMAL
# echo
# else
# $SETCOLOR_FAILURE
# echo -n "$(tput hpa $(tput cols))$(tput cub 6)[fail]"
# $SETCOLOR_NORMAL
# echo
#fi
if [ "$1" == "pick" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
yes | $BIN_PATH/futriix-server ${CONFIG_PATH} --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 --enable-protected-configs yes --enable-debug-command yes --enable-module-command yes ${ADDITIONAL_OPTIONS} >/dev/null 2>&1
if [ $? -eq 0 ]; then
$SETCOLOR_SUCCESS
echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]"
$SETCOLOR_NORMAL
echo
else
$SETCOLOR_FAILURE
echo -n "$(tput hpa $(tput cols))$(tput cub 6)[fail]"
$SETCOLOR_NORMAL
echo
fi
done
exit 0
fi
if [ "$1" == "run" ]
then
HOSTS=""
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
HOSTS="$HOSTS $CLUSTER_HOST:$PORT"
done
OPT_ARG=""
if [ "$2" == "-f" ]; then
OPT_ARG="--cluster-yes"
fi
yes | $BIN_PATH/futriix-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG >/dev/null 2>&1
exit 0
fi
if [ $? -eq 0 ]; then
$SETCOLOR_SUCCESS
echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]"
$SETCOLOR_NORMAL
echo
else
$SETCOLOR_FAILURE
echo -n "$(tput hpa $(tput cols))$(tput cub 6)[fail]"
$SETCOLOR_NORMAL
echo
fi
if [ "$1" == "stop" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
$BIN_PATH/futriix-cli -p $PORT shutdown nosave
done
exit 0
fi
if [ "$1" == "repick" ]
then
OLD_PORT=$PORT
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
$BIN_PATH/futriix-cli -p $PORT shutdown nosave
done
PORT=$OLD_PORT
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "picking $PORT"
$BIN_PATH/futriix-server ${CONFIG_PATH} --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 --enable-protected-configs yes --enable-debug-command yes --enable-module-command yes ${ADDITIONAL_OPTIONS}
done
exit 0
fi
if [ "$1" == "watch" ]
then
PORT=$((PORT+1))
while [ 1 ]; do
clear
date
$BIN_PATH/futriix-cli -p $PORT cluster nodes | head -30
sleep 1
done
exit 0
fi
if [ "$1" == "tail" ]
then
INSTANCE=$2
PORT=$((PORT+INSTANCE))
tail -f ${PORT}.log
exit 0
fi
if [ "$1" == "tailall" ]
then
tail -f *.log
exit 0
fi
if [ "$1" == "call" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
$BIN_PATH/valkey-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
done
exit 0
fi
if [ "$1" == "clean" ]
then
echo "Cleaning *.log"
rm -rf *.log
echo "Cleaning appendonlydir-*"
rm -rf appendonlydir-*
echo "Cleaning dump-*.rdb"
rm -rf dump-*.rdb
echo "Cleaning nodes-*.conf"
rm -rf nodes-*.conf
exit 0
fi
if [ "$1" == "clean-logs" ]
then
echo "Cleaning *.log"
rm -rf *.log
exit 0
fi
echo ""
echo "Usage: $0 [pick|run|stop|restart|watch|tail|tailall|clean|clean-logs|call]"
echo "pick -- Launch Futriix Cluster instances."
echo "run [-f] -- Create a cluster using futriix-cli --cluster create."
echo "stop -- Stop Futriix Cluster instances."
echo "restart -- Restart Futriix Cluster instances."
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 "tailall -- Run tail -f for all the log files at once."
echo "clean -- Remove all instances data, logs, configs."
echo "clean-logs -- Remove just instances logs."
echo "call <cmd> -- Call a command (up to 7 arguments) on all nodes."
echo ""