This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e23e3a6
commit ce09ebf
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |