#!/bin/sh # Start Redis server in the background redis-server /usr/local/etc/redis/redis.conf & # Wait for Redis server to start sleep 5 # Only initialize the cluster from one node to prevent race conditions if [ "$HOSTNAME" = "redis-node-1" ]; then echo "Initializing Redis Cluster..." yes yes | redis-cli --cluster create \ redis-node-1:6379 \ redis-node-2:6379 \ redis-node-3:6379 \ --cluster-replicas 0 fi # Keep the container running tail -f /dev/null