Last active
May 9, 2016 18:20
-
-
Save jbrisbin/57ebb53c57fa24a081a2536d7ae3ab26 to your computer and use it in GitHub Desktop.
Start and stop a 5-node Riak TS cluster using the Docker image
This file contains hidden or 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
#!/bin/bash | |
eval $(docker-machine env --shell=bash) | |
eval $(weave env) | |
CLUSTER_NAME=${2:-dev} | |
WEAVE=`which weave` | |
if [ "" == "$WEAVE" ]; then | |
LINK="--link ${CLUSTER_NAME}1" | |
fi | |
start() { | |
echo "Starting ${CLUSTER_NAME}1: $(docker run -d --name ${CLUSTER_NAME}1 -P basho/riak-ts)" | |
docker exec ${CLUSTER_NAME}1 riak-admin wait-for-service riak_kv | |
for i in {2..5}; do | |
echo "Starting ${CLUSTER_NAME}$i: $(docker run -d --name ${CLUSTER_NAME}$i -e CLUSTER1=${CLUSTER_NAME}1 $LINK -P basho/riak-ts)" | |
docker exec ${CLUSTER_NAME}$i riak-admin wait-for-service riak_kv | |
done | |
docker exec ${CLUSTER_NAME}1 riak-admin cluster status | |
} | |
stop() { | |
for i in {1..5}; do | |
docker rm --force ${CLUSTER_NAME}$i | |
done | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
*) | |
echo "Usage: $0 {start|stop}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment