Skip to content

Commit 9292e56

Browse files
authored
cluster script fixes to support future cluster versions and redis unstable (#1900)
1 parent 26491dc commit 9292e56

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-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"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# produces redisfab/redis-py-sentinel:unstable
2+
FROM ubuntu:bionic as builder
3+
RUN apt-get update
4+
RUN apt-get upgrade -y
5+
RUN apt-get install -y build-essential git
6+
RUN mkdir /build
7+
WORKDIR /build
8+
RUN git clone https://github.com/redis/redis
9+
WORKDIR /build/redis
10+
RUN make
11+
12+
FROM ubuntu:bionic as runner
13+
COPY --from=builder /build/redis/src/redis-server /usr/bin/redis-server
14+
COPY --from=builder /build/redis/src/redis-cli /usr/bin/redis-cli
15+
COPY --from=builder /build/redis/src/redis-sentinel /usr/bin/redis-sentinel
16+
17+
CMD ["redis-sentinel", "/sentinel.conf"]

docker/base/create_cluster.sh

Lines changed: 23 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,18 @@ 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+
if [ -z "${REDIS_PASSWORD}" ]; then
42+
echo yes | redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
43+
else
44+
echo yes | redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
45+
fi
2846
tail -f /redis.log

0 commit comments

Comments
 (0)