-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtasks
executable file
·122 lines (99 loc) · 2.82 KB
/
tasks
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
#!/usr/bin/env bash
#####################################################################
#
# Run ./tasks help for a list of available tasks
#
#####################################################################
# Enable shell strict mode
set -euo pipefail
# source environment variables from local env file if it exists
ENV_FILE=".env"
if [[ -f "${ENV_FILE}" ]]; then
source "${ENV_FILE}"
fi
SINGLESTORE_LICENSE="${SINGLESTORE_LICENSE:-}"
# prompt the user for license key if it's not provided in a environment variable
if [[ -z "${SINGLESTORE_LICENSE}" ]]; then
# prompt the user until they enter a valid license key
while [[ -z "${SINGLESTORE_LICENSE}" ]]; do
echo "SINGLESTORE_LICENSE environment variable not found"
echo "You can get a free SingleStore license key from https://portal.singlestore.com/"
echo "Please enter your SingleStore license key:"
read SINGLESTORE_LICENSE
done
# save the license key to the environment file for future use
echo "export SINGLESTORE_LICENSE='${SINGLESTORE_LICENSE}'" >>"${ENV_FILE}"
fi
help() {
cat <<EOF
Usage: ./tasks <task> [<args>]
tasks:
up: (re)start all containers
down: stop all containers
status: show status of containers
logs [SERVICE]: show logs of a service
rpk: run a Redpanda command (run ./tasks rpk for help)
monitoring: (re)start prometheus and grafana
storage: (re)start singlestore and redpanda
simulator: (re)start simulator
stop-simulator: stop simulator
api: (re)start api
stop-api: stop api
EOF
}
status() {
docker-compose ps
}
logs() {
local service=${1:-}
docker-compose logs --tail 100 -f ${service}
}
rpk() {
docker exec -it -e REDPANDA_BROKERS=redpanda:9092 redpanda rpk "${@}"
}
monitoring() {
docker-compose rm -fsv prometheus grafana
docker-compose up -d prometheus grafana
}
storage() {
docker-compose rm -fsv singlestore redpanda
docker-compose up -d redpanda
sleep 1
rpk topic create test --partitions 8
rpk topic create events --partitions 8
docker-compose up -d singlestore
}
simulator() {
docker-compose rm -fsv simulator
docker-compose up --build -d simulator
docker-compose logs --tail=10 simulator
}
stop-simulator() {
docker-compose rm -fsv simulator
}
api() {
docker-compose rm -fsv api
docker-compose up --build -d api
docker-compose logs --tail=10 api
}
stop-api() {
docker-compose rm -fsv api
}
down() {
docker-compose down -v
}
up() {
down
monitoring
storage
simulator
api
status
}
type ${1:-help} >/dev/null 2>&1 || {
echo "Unknown command: ${1:-help}"
echo
help
exit 1
}
"${@:-help}"