File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,9 +110,27 @@ jobs:
110110 sudo apt update
111111 sudo apt-get install -y --fix-missing redis-server
112112 sudo service redis-server stop
113- redis-server --daemonize yes --port 7000 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7000.conf
114- redis-server --daemonize yes --port 7001 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7001.conf
115- redis-server --daemonize yes --port 7002 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7002.conf
113+
114+ for port in 7000 7001 7002; do
115+ redis-server --daemonize yes --port "$port" --appendonly yes --cluster-enabled yes --cluster-config-file "nodes-$port.conf"
116+ done
117+
118+ # --daemonize returns as soon as the parent forks, before the node
119+ # accepts connections, so creating the cluster straight away races
120+ # the last node into a refused connection. Wait for every node to
121+ # answer PING first.
122+ for port in 7000 7001 7002; do
123+ for attempt in $(seq 30); do
124+ if [ "$(redis-cli -p "$port" ping 2>/dev/null)" = "PONG" ]; then
125+ continue 2
126+ fi
127+ sleep 1
128+ done
129+
130+ echo "Redis node on port $port never started accepting connections."
131+ exit 1
132+ done
133+
116134 redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 0 --cluster-yes
117135
118136 - name : Check Redis Cluster is ready
You can’t perform that action at this time.
0 commit comments