Skip to content

Commit 91cde91

Browse files
committed
unstable cluster fix - and future clusters via the shell script
1 parent 0763441 commit 91cde91

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

docker/base/Dockerfile.cluster

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ RUN chmod +x /create_cluster.sh
66

77
EXPOSE 16379 16380 16381 16382 16383 16384
88

9-
CMD /create_cluster.sh 16379 16384
9+
ENV START_PORT=16379
10+
ENV END_PORT=16384
11+
CMD /create_cluster.sh

docker/base/Dockerfile.unstable_cluster

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ RUN chmod +x /create_cluster.sh
66

77
EXPOSE 6372 6373 6374 6375 6376 6377
88

9-
CMD /create_cluster.sh 6372 6377
9+
ENV START_PORT=6372
10+
ENV END_PORT=6377
11+
CMD ["/create_cluster.sh"]

docker/base/create_cluster.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
#! /bin/bash
2+
23
mkdir -p /nodes
34
touch /nodes/nodemap
4-
START_NODE=$1
5-
END_NODE=$2
6-
for PORT in `seq ${START_NODE} ${END_NODE}`; do
5+
if [ -z ${START_PORT}]; then
6+
START_PORT=16379
7+
fi
8+
if [ -z ${END_PORT}]; then
9+
END_PORT=16384
10+
fi
11+
if [ ! -z "$3" ]; then
12+
START_PORT=$2
13+
START_PORT=$3
14+
fi
15+
echo "STARTING: ${START_PORT}"
16+
echo "ENDING: ${END_PORT}"
17+
18+
for PORT in `seq ${START_PORT} ${END_PORT}`; do
719
mkdir -p /nodes/$PORT
820
if [[ -e /redis.conf ]]; then
921
cp /redis.conf /nodes/$PORT/redis.conf
@@ -17,12 +29,14 @@ daemonize yes
1729
logfile /redis.log
1830
dir /nodes/$PORT
1931
EOF
32+
33+
set -x
2034
redis-server /nodes/$PORT/redis.conf
2135
if [ $? -ne 0 ]; then
2236
echo "Redis failed to start, exiting."
23-
exit 3
37+
continue
2438
fi
2539
echo 127.0.0.1:$PORT >> /nodes/nodemap
2640
done
27-
echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g ${START_NODE} ${END_NODE}) --cluster-replicas 1
41+
echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}) --cluster-replicas 1
2842
tail -f /redis.log

0 commit comments

Comments
 (0)