Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
add run_single_node script
Browse files Browse the repository at this point in the history
  • Loading branch information
J-HowHuang committed May 1, 2024
1 parent e23e3a6 commit ce09ebf
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions server/run_single_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# The ports where Redis nodes are running
ports=(6379)
NODE_1_IP="${NODE_1_IP:-"localhost"}":6379
NODE_2_IP="${NODE_2_IP:-"localhost"}":6379
NODE_3_IP="${NODE_3_IP:-"localhost"}":6379

# Loop over each port and flush all databases then perform a hard reset on the cluster
for port in "${ports[@]}"
do
echo "Flushing all databases on port $port..."
redis-cli -p "$port" FLUSHALL
done

for port in "${ports[@]}"
do
echo "Performing a hard reset on the cluster node running on port $port..."
redis-cli -p "$port" CLUSTER RESET HARD
done

echo "All specified Redis nodes have been flushed and had a hard reset."

# Directory to store logs
LOG_DIR="./logs"
mkdir -p "${LOG_DIR}"

# Server root directory
SERVER_ROOT="${SERVER_ROOT:-"."}"

# Names or keywords to identify your processes
PROCESS_NAMES=("istziio_server_node" "redis-serveredis-serverr")

# Kill existing processes based on the names or keywords
for name in "${PROCESS_NAMES[@]}"; do
pkill -f $name
done

echo "Existing processes killed, if any were running."

# Start Redis instances
redis-server $SERVER_ROOT/redis.conf --port 6379 --cluster-config-file node1.conf&

echo "Redis servers starting..."

sleep 5

# Creating the cluster
redis-cli --cluster create $NODE_1_IP $NODE_2_IP $NODE_3_IP --cluster-replicas 0 --cluster-yes

sleep 5
echo "Redis cluster created."

# Starting the application servers
REDIS_PORT=6379 cargo run --\
--bucket "istziio-bucket" \
--region "us-east-1" \
--access-key "$AWS_ACCESS_KEY_ID" \
--secret-key "$AWS_SECRET_ACCESS_KEY" > "${LOG_DIR}/app_6379.log" 2>&1 &

echo "Application servers starting..."

# Reminder to check logs
echo "Check ${LOG_DIR} for logs."

0 comments on commit ce09ebf

Please sign in to comment.