Skip to content

Commit 5626209

Browse files
committed
Updating quickstart
1 parent b504f56 commit 5626209

File tree

2 files changed

+84
-54
lines changed

2 files changed

+84
-54
lines changed

docs/quick-start.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ If you were following the [Quicker Start](#quicker-start) or if you don't want t
226226
curl -sLo- https://raw.githubusercontent.com/yahoo/bullet-docs/v0.1.4/examples/install-all.sh | bash -s cleanup
227227
```
228228

229-
If you were performing the steps yourself, you can also manually cleanup all the components we bought up using:
230-
231-
| | |
232-
| -------------- | ----------------------------------------------------------------------------------- |
233-
| UI | ```ps aux | grep [e]xpress-server.js | awk '{print $2}' | xargs kill``` |
234-
| Web Service | ```ps aux | grep [e]xample_context.properties | awk '{print $2}' | xargs kill``` |
235-
| Storm | ```ps aux | grep [a]pache-storm-1.0.3 | awk '{print $2}' | xargs kill``` |
236-
| File System | ```rm -rf $BULLET_HOME /tmp/dev-storm-zookeeper /tmp/jetty-*``` |
229+
If you were performing the steps yourself, you can also manually cleanup **all the components and all the downloads** using:
230+
231+
| | |
232+
| -------------- | ---------------------------------------------------------------- |
233+
| UI | ```pkill -f [e]xpress-server.js``` |
234+
| Web Service | ```pkill -f [e]xample_context.properties``` |
235+
| Storm | ```pkill -f [a]pache-storm-1.0.3``` |
236+
| File System | ```rm -rf $BULLET_HOME /tmp/dev-storm-zookeeper /tmp/jetty-*``` |
237237

238238
This does *not* delete ```$HOME/.nvm``` and some extra lines nvm may have added to your ```$HOME/{.profile, .bash_profile, .zshrc, .bashrc}```.
239239

examples/install-all.sh

Lines changed: 76 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -euo pipefail
44

5-
BULLET_EXAMPLES_VERSION=0.1.4
5+
BULLET_EXAMPLES_VERSION=0.2.0
66
BULLET_UI_VERSION=0.1.0
77
BULLET_WS_VERSION=0.0.1
88
JETTY_VERSION=9.3.16.v20170120
@@ -11,11 +11,9 @@ NVM_VERSION=0.33.1
1111
NODE_VERSION=6.9.4
1212

1313
println() {
14-
local DATE="$(date)"
15-
local FORMAT=$1
16-
shift
17-
printf "${DATE} [BULLET-QUICKSTART]: "
18-
printf "${FORMAT}\n" $*
14+
local DATE
15+
DATE="$(date)"
16+
printf "%s [BULLET-QUICKSTART] %s\n" "${DATE}" "$1"
1917
}
2018

2119
print_versions() {
@@ -30,46 +28,61 @@ print_versions() {
3028
println "Done!"
3129
}
3230

31+
download() {
32+
local URL="$1"
33+
local FILE="$2"
34+
35+
local FILE_PATH="${BULLET_DOWNLOADS}/${FILE}"
36+
37+
if [[ -s "${FILE_PATH}" ]]; then
38+
println "Download exists in ${FILE_PATH}. Skipping download..."
39+
else
40+
cd "${BULLET_DOWNLOADS}" && { curl --retry 2 -#LO "${URL}/${FILE}" ; cd - &> /dev/null; }
41+
fi
42+
}
43+
3344
export_vars() {
34-
local PWD="$(pwd)"
45+
local PWD
46+
PWD="$(pwd)"
3547

3648
println "Exporting some variables..."
3749
export BULLET_HOME="${PWD}/bullet-quickstart"
3850
export BULLET_EXAMPLES=$BULLET_HOME/bullet-examples
51+
export BULLET_DOWNLOADS=$BULLET_HOME/bullet-downloads
3952
println "Done!"
4053
}
4154

4255
setup() {
4356
println "Setting up directories..."
44-
mkdir -p $BULLET_HOME/backend/storm
45-
mkdir -p $BULLET_HOME/service
46-
mkdir -p $BULLET_HOME/ui
57+
mkdir -p "${BULLET_HOME}/backend/storm"
58+
mkdir -p "${BULLET_HOME}/service"
59+
mkdir -p "${BULLET_HOME}/ui"
60+
mkdir -p "${BULLET_DOWNLOADS}"
4761
println "Done!"
4862
}
4963

5064
install_bullet_examples() {
51-
cd "${BULLET_HOME}"
5265
println "Downloading Bullet Examples ${BULLET_EXAMPLES_VERSION}..."
53-
curl --retry 2 -#LO "https://github.com/yahoo/bullet-docs/releases/download/v${BULLET_EXAMPLES_VERSION}/examples_artifacts.tar.gz"
66+
download "https://github.com/yahoo/bullet-docs/releases/download/v${BULLET_EXAMPLES_VERSION}" "examples_artifacts.tar.gz"
67+
5468
println "Installing Bullet Examples..."
55-
tar -xzf examples_artifacts.tar.gz
69+
tar -xzf "${BULLET_DOWNLOADS}/examples_artifacts.tar.gz" -C "${BULLET_HOME}"
5670
println "Done!"
5771
}
5872

5973
install_storm() {
6074
local STORM="apache-storm-${STORM_VERSION}"
61-
62-
cd "${BULLET_HOME}/backend"
75+
local BACKEND="${BULLET_HOME}/backend/"
6376

6477
println "Downloading Storm ${STORM_VERSION}..."
65-
curl --retry 2 -#O "http://apache.org/dist/storm/${STORM}/${STORM}.zip"
78+
download "http://apache.org/dist/storm/${STORM}" "${STORM}.zip"
6679

6780
println "Installing Storm ..."
68-
unzip -qq "${STORM}.zip"
81+
unzip -qq "${BULLET_DOWNLOADS}/${STORM}.zip" -d "${BACKEND}"
6982

7083
println "Configuring Storm ..."
71-
export PATH="$BULLET_HOME/backend/${STORM}/bin/:${PATH}"
72-
echo 'drpc.servers: ["127.0.0.1"]' >> "${STORM}/conf/storm.yaml"
84+
export PATH="${BACKEND}/${STORM}/bin/:${PATH}"
85+
echo 'drpc.servers: ["127.0.0.1"]' >> "${BACKEND}/${STORM}/conf/storm.yaml"
7386
println "Done!"
7487
}
7588

@@ -96,7 +109,6 @@ launch_storm() {
96109
println "=============================================================================="
97110
sleep 60
98111
println "=============================================================================="
99-
println ""
100112
println "Done!"
101113
}
102114

@@ -105,12 +117,14 @@ launch_bullet_storm() {
105117
cp "${BULLET_EXAMPLES}/storm"/* "${BULLET_HOME}/backend/storm"
106118

107119
println "Launching the Bullet topology..."
120+
println "=============================================================================="
108121
cd "${BULLET_HOME}/backend/storm" && ./launch.sh
122+
println "=============================================================================="
123+
println "Done!"
109124
println "Sleeping for 30 s to ensure all Bullet Storm components are up..."
110125
println "=============================================================================="
111126
sleep 30
112127
println "=============================================================================="
113-
println ""
114128

115129
println "Testing the Storm topology"
116130
println ""
@@ -120,28 +134,30 @@ launch_bullet_storm() {
120134
}
121135

122136
install_jetty() {
123-
cd "${BULLET_HOME}/service"
137+
local SERVICE="${BULLET_HOME}/service"
138+
local JETTY_DISTRIBUTION="jetty-distribution-${JETTY_VERSION}.zip"
124139

125140
println "Downloading Jetty ${JETTY_VERSION}..."
126-
curl --retry 2 -#O "http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${JETTY_VERSION}/jetty-distribution-${JETTY_VERSION}.zip"
141+
download "http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${JETTY_VERSION}" "${JETTY_DISTRIBUTION}"
127142

128143
println "Installing Jetty..."
129-
unzip -qq "jetty-distribution-${JETTY_VERSION}.zip"
144+
unzip -qq "${BULLET_DOWNLOADS}/${JETTY_DISTRIBUTION}" -d "${SERVICE}"
130145
println "Done!"
131146
}
132147

133148
launch_bullet_web_service() {
134-
cd "${BULLET_HOME}/service/jetty-distribution-${JETTY_VERSION}"
149+
local BULLET_WS_WAR="bullet-service-${BULLET_WS_VERSION}.war"
150+
local JETTY_INSTALLATION="${BULLET_HOME}/service/jetty-distribution-${JETTY_VERSION}"
135151

136152
println "Downloading Bullet Web Service ${BULLET_WS_VERSION}..."
137-
curl --retry 2 -#Lo webapps/bullet-service.war \
138-
"http://jcenter.bintray.com/com/yahoo/bullet/bullet-service/${BULLET_WS_VERSION}/bullet-service-${BULLET_WS_VERSION}.war"
153+
download "http://jcenter.bintray.com/com/yahoo/bullet/bullet-service/${BULLET_WS_VERSION}" "${BULLET_WS_WAR}"
139154

140155
println "Configuring Bullet Web Service..."
141-
cp "${BULLET_EXAMPLES}/web-service"/example_* "${BULLET_HOME}/service/jetty-distribution-${JETTY_VERSION}"
156+
cp "${BULLET_DOWNLOADS}/${BULLET_WS_WAR}" "${JETTY_INSTALLATION}/webapps/bullet-service.war"
157+
cp "${BULLET_EXAMPLES}/web-service/"example_* "${JETTY_INSTALLATION}"
142158

143159
println "Launching Bullet Web Service..."
144-
cd "${BULLET_HOME}/service/jetty-distribution-${JETTY_VERSION}"
160+
cd "${JETTY_INSTALLATION}"
145161
java -jar -Dbullet.service.configuration.file="example_context.properties" -Djetty.http.port=9999 start.jar > logs/out 2>&1 &
146162

147163
println "Sleeping for 30 s to ensure Bullet Web Service is up..."
@@ -159,32 +175,41 @@ launch_bullet_web_service() {
159175
}
160176

161177
install_node() {
178+
# NVM unset var bug
179+
set +u
180+
181+
println "Trying to install nvm. If there is a failure, manually perform: "
182+
println " curl -s https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash"
183+
println " nvm install v${NODE_VERSION}"
184+
println " nvm use v${NODE_VERSION}"
185+
println "and then try this script again..."
186+
162187
println "Downloading and installing NVM ${NVM_VERSION}..."
163188
curl --retry 2 -s "https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh" | bash
164189

165-
# NVM unset var bug
166-
set +u
167190
println "Loading nvm into current environment if installation successful..."
168-
export NVM_DIR="$HOME/.nvm"
169-
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
191+
[ -s "${HOME}/.nvm/nvm.sh" ] && source "${HOME}/.nvm/nvm.sh"
170192
println "Done!"
171193

172194
println "Installing Node ${NODE_VERSION}..."
173195
nvm install "v${NODE_VERSION}"
174196
nvm use "v${NODE_VERSION}"
197+
175198
set -u
176199

177200
println "Done!"
178201
}
179202

180203
launch_bullet_ui() {
181-
cd "${BULLET_HOME}/ui"
204+
local BULLET_UI_ARCHIVE="bullet-ui-v${BULLET_UI_VERSION}.tar.gz"
182205

183206
println "Downloading Bullet UI ${BULLET_UI_VERSION}..."
184-
curl --retry 2 -#LO "https://github.com/yahoo/bullet-ui/releases/download/v${BULLET_UI_VERSION}/bullet-ui-v${BULLET_UI_VERSION}.tar.gz"
207+
download "https://github.com/yahoo/bullet-ui/releases/download/v${BULLET_UI_VERSION}" "${BULLET_UI_ARCHIVE}"
208+
209+
cd "${BULLET_HOME}/ui"
185210

186211
println "Installing Bullet UI..."
187-
tar -xzf "bullet-ui-v${BULLET_UI_VERSION}.tar.gz"
212+
tar -xzf "${BULLET_DOWNLOADS}/${BULLET_UI_ARCHIVE}"
188213

189214
println "Configuring Bullet UI..."
190215
cp "${BULLET_EXAMPLES}/ui/env-settings.json" config/
@@ -198,29 +223,29 @@ launch_bullet_ui() {
198223
}
199224

200225
cleanup() {
201-
set +eo pipefail
226+
set +e
202227

203-
ps aux | grep "[a]pache-storm-${STORM_VERSION}" | awk '{print $2}' | xargs kill
204-
205-
ps aux | grep "[e]xpress-server.js" | awk '{print $2}' | xargs kill
206-
207-
ps aux | grep "[e]xample_context.properties" | awk '{print $2}' | xargs kill
228+
pkill -f "[a]pache-storm-${STORM_VERSION}"
229+
pkill -f "[e]xpress-server.js"
230+
pkill -f "[e]xample_context.properties"
208231

209232
sleep 3
210233

211-
rm -rf "${BULLET_HOME}" /tmp/dev-storm-zookeeper /tmp/jetty-*
234+
rm -rf "${BULLET_EXAMPLES}" "${BULLET_HOME}/backend" "${BULLET_HOME}/service" \
235+
"${BULLET_HOME}/ui" /tmp/dev-storm-zookeeper /tmp/jetty-*
212236

213-
set -eo pipefail
237+
set -e
214238
}
215239

216240
teardown() {
217241
println "Killing and cleaning up all Bullet components..."
218242
cleanup &> /dev/null
219-
println "Done! Not deleting $HOME/.nvm or nvm additions to $HOME/{.profile, .bash_profile, .zshrc, .bashrc}..."
243+
println "Done!"
220244
}
221245

222246
unset_all() {
223-
unset -f print_versions println export_vars setup install_bullet_examples \
247+
unset -f print_versions println download export_vars setup \
248+
install_bullet_examples \
224249
install_storm launch_storm launch_bullet_storm \
225250
install_jetty launch_bullet_web_service \
226251
install_node launch_bullet_ui \
@@ -251,8 +276,13 @@ launch() {
251276
}
252277

253278
clean() {
279+
println "Launching cleanup..."
254280
export_vars
255281
teardown
282+
println "Not deleting ${BULLET_DOWNLOADS}, ${HOME}/.nvm or nvm additions to ${HOME}/{.profile, .bash_profile, .zshrc, .bashrc}..."
283+
println "Cleaned up ${BULLET_HOME} and /tmp"
284+
println "To delete all download artifacts (excluding nvm), do:"
285+
println " rm -rf ${BULLET_HOME}"
256286
unset_all
257287
}
258288

0 commit comments

Comments
 (0)