This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup
executable file
·58 lines (49 loc) · 2.85 KB
/
setup
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
#!/usr/bin/env bash
set -e
setup_dedicated () {
heroku addons:create heroku-postgresql:hobby-dev --as HEROKU_POSTGRESQL -a ${APP_NAME} && \
heroku addons:create heroku-kafka:${PLAN} --as HEROKU_KAFKA -a ${APP_NAME} && \
heroku kafka:wait -a ${APP_NAME} && \
heroku kafka:topics:create textlines --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create words --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create loglines --partitions 5 -a ${APP_NAME}
heroku kafka:topics:create aggregator-app-windowed-counts-changelog --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create aggregator-app-windowed-counts-repartition --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create anomaly-detector-app-windowed-counts-changelog --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create anomaly-detector-app-windowed-counts-repartition --partitions 5 -a ${APP_NAME} && \
}
setup_multi_tenant () {
heroku addons:create heroku-postgresql:hobby-dev --as HEROKU_POSTGRESQL -a ${APP_NAME} && \
heroku addons:create heroku-kafka:${PLAN} --as HEROKU_KAFKA -a ${APP_NAME} && \
heroku kafka:wait -a ${APP_NAME} && \
heroku kafka:topics:create textlines --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create words --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create loglines --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create aggregator-app-windowed-counts-changelog --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create aggregator-app-windowed-counts-repartition --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create anomaly-detector-app-windowed-counts-changelog --partitions 5 -a ${APP_NAME} && \
heroku kafka:topics:create anomaly-detector-app-windowed-counts-repartition --partitions 5 -a ${APP_NAME} && \
heroku kafka:consumer-groups:create anomaly-detector-app -a ${APP_NAME} && \
heroku kafka:consumer-groups:create text-processor-app -a ${APP_NAME} && \
heroku kafka:consumer-groups:create aggregator-app -a ${APP_NAME}
}
if [[ -z $1 ]]; then
echo "usage: $0 APP_NAME PLAN" >&2
exit 1
fi
APP_NAME=$1
if [[ $2 =~ (standard|basic|extended|private-standard|private-extended)-[012] ]]; then
PLAN=$2
else
PLAN="basic-0"
fi
if [[ $PLAN =~ basic-[012] ]]; then
setup_multi_tenant
else
setup_dedicated
fi
heroku pg:psql -c 'CREATE TABLE windowed_counts(id serial primary key NOT NULL, time_window bigint NOT NULL, word text, count bigint NOT NULL);' HEROKU_POSTGRESQL_URL -a ${APP_NAME}
heroku pg:psql -c 'CREATE UNIQUE INDEX windowed_counts_time_window_word ON windowed_counts(word text_ops,time_window int8_ops);' HEROKU_POSTGRESQL_URL -a ${APP_NAME}
heroku ps:scale text_processor_worker=1 -a ${APP_NAME}
heroku ps:scale aggregator_worker=1 -a ${APP_NAME}
# heroku ps:scale anomaly_detector_worker=1 -a ${APP_NAME} # Can't run more than 2 free dynos.