forked from viki-org/storm-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-storm.sh
executable file
·202 lines (197 loc) · 7.28 KB
/
start-storm.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
# This is used to run a Docker container in this repository after you have
# run the `make` command to build the Docker images.
# Inspects the `IMAGE` column of the output of `docker ps` to see if the given
# Docker container is running
function is_docker_container_running {
docker ps | tail -n+2 | awk '{print $2}' | grep --quiet $1
}
# Starts a given storm-docker Docker container
function start_storm_docker {
case $1 in
nimbus)
if is_docker_container_running "viki_data/storm-nimbus"
then
echo "storm nimbus Docker container already running"
else
scripts/run-storm-docker-component.sh \
--name nimbus \
--link zookeeper:zk \
-h nimbus \
-d viki_data/storm-nimbus \
--storm-docker-component nimbus \
--storm-docker-component drpc
fi
;;
nimbus-with-zookeeper-ambassador)
# Implemented for https://github.com/viki-org/storm-docker/issues/5
# which lets the user run the Nimbus docker container on a separate physical
# machine from any of the machine(s) running a Zookeeper docker container.
# This server will run a Zookeeper along with an ambassador.
# We add a `--dont-expose-ports` argument to get the
# `docker_python_helpers/run-zookeeper.py` script to generate a `docker run`
# command without `-p` flags that expose the ports on the host machine.
if is_docker_container_running "viki_data/storm-nimbus" && \
is_docker_container_running "zk_ambassador"
then
echo "storm nimbus Docker container already running"
echo "zookeeper ambassador Docker container already running"
elif is_docker_container_running "viki_data/storm-nimbus"
then
echo "storm nimbus Docker container already running"
scripts/run-storm-nimbus.sh \
--name zk_ambassador -h zk_ambassador -d svendowideit/ambassador
elif is_docker_container_running "zk_ambassador"
then
echo "zookeeper ambassador Docker container already running"
scripts/run-storm-nimbus.sh \
--nimbus-args-after-this \
--name nimbus \
--link zk_ambassador:zk \
-h nimbus \
-d viki_data/storm-nimbus \
--storm-docker-component nimbus \
--storm-docker-component drpc
else
scripts/run-storm-nimbus.sh \
--name zk_ambassador -h zk_ambassador -d svendowideit/ambassador \
--nimbus-args-after-this \
--name nimbus \
--link zk_ambassador:zk \
-h nimbus \
-d viki_data/storm-nimbus \
--storm-docker-component nimbus \
--storm-docker-component drpc
fi
;;
supervisor)
if is_docker_container_running "viki_data/storm-supervisor"
then
echo "storm supervisor Docker container already running"
else
scripts/run-storm-supervisor.sh \
--dns 127.0.0.1 --dns 8.8.8.8 --dns 8.8.4.4 \
-p 127.0.0.1:49022:22 \
--name supervisor \
-d viki_data/storm-supervisor
fi
;;
ui)
if is_docker_container_running "viki_data/storm-ui"
then
echo "storm ui Docker container already running"
else
scripts/run-storm-docker-component.sh \
--name ui \
--link nimbus:nimbus --link zookeeper:zk \
-d viki_data/storm-ui \
--storm-docker-component ui
fi
;;
ui-on-zk-ambassador-machine)
if is_docker_container_running "viki_data/storm-ui"
then
echo "storm ui Docker container already running"
else
scripts/run-storm-docker-component.sh \
--name ui \
--link nimbus:nimbus --link zk_ambassador:zk \
-d viki_data/storm-ui \
--storm-docker-component ui
fi
;;
zookeeper)
if is_docker_container_running "viki_data/zookeeper"
then
echo "zookeeper Docker container already running"
else
scripts/run-zookeeper.sh \
-p 127.0.0.1:49122:22 \
-h zookeeper --name zookeeper \
-d viki_data/zookeeper
fi
;;
zookeeper-with-ambassador)
# This server will run a Zookeeper along with an ambassador.
# We add a `--dont-expose-ports` argument to get the
# `docker_python_helpers/run-zookeeper.py` script to generate a `docker run`
# command without `-p` flags that expose the ports on the host machine.
if is_docker_container_running "viki_data/zookeeper" && \
is_docker_container_running "zk_ambassador"
then
echo "zookeeper Docker container already running"
echo "zookeeper ambassador Docker container already running"
elif is_docker_container_running "viki_data/zookeeper"
then
scripts/run-zookeeper.sh \
--no-zookeeper \
-- \
--link zookeeper:zk --name zk_ambassador -d svendowideit/ambassador
elif is_docker_container_running "zk_ambassador"
then
scripts/run-zookeeper.sh \
-p 127.0.0.1:49122:22 \
-h zookeeper --name zookeeper \
-d viki_data/zookeeper \
--no-dash-p
else
scripts/run-zookeeper.sh \
-p 127.0.0.1:49122:22 \
-h zookeeper --name zookeeper \
-d viki_data/zookeeper \
--no-dash-p \
-- \
--link zookeeper:zk --name zk_ambassador -d svendowideit/ambassador
fi
;;
*)
echo "Unknown storm-docker component: \"$1\""
;;
esac
}
# Execution of this bash script starts from here
if [ $# -eq 0 ] || [ "$1" = "--help" ]
then
echo "Runs a Docker container built by this repository."
echo "You can supply one or more of the following args:"
echo ""
echo -e " nimbus - Runs the nimbus" \
"container. This is for a machine which already has a running Zookeeper" \
"container. (components: Storm Nimbus, Storm DRPC)\n"
echo -e " nimbus-with-zookeeper-ambassador - Runs the nimbus" \
"container AND a Zookeeper ambassador container. This is for a machine" \
"which does NOT have a running Zookeeper container.\n"
echo -e " supervisor - Runs the supervisor" \
"container (components: Storm Supervisor, Storm Logviewer)\n"
echo -e " ui - Runs the ui container." \
"This option should be used on the same machine where the 'nimbus'" \
"argument was used. (components: Storm UI)\n"
echo -e " ui-on-zk-ambassador-machine - Runs the ui container." \
"This option should be used on the same machine where the" \
"'nimbus-with-zookeeper-ambassador' argument was used.\n"
echo -e " zookeeper - Runs the zookeeper" \
"container (components: Zookeeper)\n"
echo -e " zookeeper-with-ambassador - Runs a Zookeeper" \
"container and an ambassador container for Zookeeper\n"
echo -e " all - Similar to running the" \
"zookeeper, nimbus, ui and supervisor commands separately (in order)"
echo ""
echo "For example, to run the zookeeper and ui containers, run:"
echo ""
echo " ./start-storm.sh zookeeper ui"
echo ""
elif [ "$1" = "all" ]
then
# No arguments supplied to this script; run every component
start_storm_docker "zookeeper"
start_storm_docker "nimbus"
start_storm_docker "ui"
start_storm_docker "supervisor"
else
# At least one argument was supplied to this script.
# We start each Docker container in the arguments.
for component in "$@"
do
start_storm_docker $component
done
fi