-
Notifications
You must be signed in to change notification settings - Fork 15
/
cluster.sh
68 lines (58 loc) · 1.49 KB
/
cluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#
# Author: Jason Giedymin <jason dot giedymin -at- gmail dot com>
# License: Apache2
# Desc: Basic cluster script for cassandra using docker.
# This is meant for local development, though you could
# boot this up onto a docker-machine cluster. If you do
# indeed embark on that journey pay particular attention
# to the port specs in the compose yaml. It may be more
# than you'd want for production. Also consider a service
# container exposed with ports that are linked instead.
#
# If you desire logging, supply COMPOSE_LOG=true like so:
# COMPOSE_LOG=true bash cluster.sh up
# A file named compose.log will appear.
#
COMPOSE_LOG=${COMPOSE_LOG:false}
function removeContainers() {
docker-compose rm -fv cassandra-1
docker-compose rm -fv cassandra-2
}
function removeData() {
# [[ -e ./data ]] && rm -R ./data
[[ -e ./cassandra-1 ]] && rm -R ./cassandra-1
[[ -e ./cassandra-2 ]] && rm -R ./cassandra-2
}
function createData() {
mkdir -p ./cassandra-1/data
mkdir -p ./cassandra-2/data
}
function up() {
removeContainers
removeData
# createData # uncomment if you desire mounts
function logup() {
docker-compose up > compose.log &
}
[[ $COMPOSE_LOG = true ]] && logup || docker-compose up
}
function remove() {
docker-compose stop
removeContainers
removeData
}
case "$1" in
up)
up
;;
halt|stop|down)
docker-compose stop
;;
remove)
remove
;;
*)
echo "$0 {up|halt|stop|down|remove}"
;;
esac