-
Notifications
You must be signed in to change notification settings - Fork 9
/
start-windows.sh
executable file
·211 lines (187 loc) · 6.28 KB
/
start-windows.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
203
204
205
206
207
208
209
210
211
# export configurable env vars
OS_NAME="$(uname -s)"
if [ "$OS_NAME" = "Darwin" ]; then
echo "Running on MacOS, trying to use xargs"
export $(grep -v '^#' .env | gxargs -d '\n')
else
echo "Running on linux, using xargs"
export $(grep -v '^#' .env | xargs -d '\n')
fi
# export other env vars
export MAGNETAR_PORT=5000
export KUIPER_PORT=9001
export KUIPER_WEBHOOK_PORT=9002
export OORT_PORT=8000
export IAM_PORT=8002
export AGENT_QUEUE_PORT=50052
export NATS_PORT=4222
export ETCD_PORT=2379
export KUIPER_ETCD_PORT=2379
export NEO4J_BOLT_PORT=7687
export NEO4J_HTTP_PORT=7474
export VAULT_HTTP_PORT=8200
export STAROMETRY_HTTP_PORT=8003
export STAROMETRY_GRPC_PORT=50055
export PROMETHEUS_PORT=9090
export STAR_HOSTNAME=star
export MAGNETAR_HOSTNAME=magnetar
export KUIPER_HOSTNAME=kuiper
export OORT_HOSTNAME=oort
export NATS_HOSTNAME=nats
export ETCD_HOSTNAME=etcd
export KUIPER_ETCD_HOSTNAME=kuiper_etcd
export IAM_HOSTNAME=apollo
export AGENT_QUEUE_HOSTNAME=agent_queue
export PROMETHEUS_HOSTNAME=prometheus
export REGISTRATION_TIMEOUT=1000
export REGISTRATION_SUBJECT="register"
export NODE_ID_DIR_PATH="//etc/c12s"
export NODE_ID_FILE_NAME="nodeid"
export NEO4J_HOSTNAME=neo4j
export NEO4J_AUTH_ENABLED=false
export NEO4J_DBNAME=neo4j
export NEO4J_apoc_export_file_enabled=true
export NEO4J_apoc_import_file_enabled=true
export NEO4J_apoc_import_file_use__neo4j__config=true
export NEO4J_PLUGINS="[\"apoc\"]"
export VAULT_HOSTNAME=vault
export VAULT_ADDR=http://0.0.0.0
export VAULT_KEYS_FILE=//etc/apollo/api_key.json
export DB_PASSWORD=c12s_password
export DB_USERNAME=postgres
export DB_NAME=postgres
export DB_HOST=database
export QUASAR_HOSTNAME=quasar
export QUASAR_PORT=9090
export QUASAR_ETCD_HOSTNAME=quasar_etcd
export QUASAR_ETCD_PORT=2379
export SECRET_KEY="secret-key"
export DB_CONSUL=consul
export DBPORT_CONSUL=8500
export MERIDIAN_LISTEN_PORT=8000
export MERIDIAN_ADDRESS=meridian:8000
export MERIDIAN_NEO4J_ADDRESS=meridian_neo4j:7687
export MERIDIAN_NEO4J_DB_NAME=neo4j
export MERIDIAN_NEO4J_BOLT_PORT=7687
export MERIDIAN_NEO4J_HTTP_PORT=7474
export MERIDIAN_NEO4J_AUTH_ENABLED=false
export PULSAR_ADDRESS=pulsar:8000
export PULSAR_ETCD_ADDRESS=pulsar_etcd:2379
export PULSAR_LISTEN_ADDRESS=0.0.0.0:8000
# build contol plane's services
docker compose build --stop-on-error
# start the control plane
docker compose up -d
# scylla init
CONTAINER_NAME="scylla"
while true; do
# Get the health status of the container
HEALTH=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_NAME)
# Check if the container is healthy
if [ "$HEALTH" = "healthy" ]; then
echo "Container is healthy, running additional script"
winpty docker exec -it scylla //bin/sh -c "cqlsh -f /scylla_schema.cql"
break # Exit the loop when the container is healthy
else
echo "scylla is not healthy, waiting for 5 seconds before checking again"
sleep 5
fi
done
# export other env vars
export STAR_HOSTNAME=star
export OORT_HOSTNAME=oort
export NATS_HOSTNAME=nats
# Set Serf agent environment variables
# Address for single serf agent
export SERF_BIND_ADDRESS=0.0.0.0
export SERF_BIND_PORT=7946
# Address to contact to join cluster
export SERF_CLUSTER_ADDRESS="star_1"
export SERF_CLUSTER_PORT=7946
# String used to build tags in the serf config
export SERF_GOSSIP_TAG="tag1:type_"
# Export metrics agent
export CADVISOR_PORT=8081
export CADVISOR_INTERNAL_PORT=8080
export NODE_EXPORTER_PORT=9100
export CADVISOR_URL=cadvisor
export NODE_EXPORTER_URL=node_exporter
export NODE_EXPORTER_INTERNAL_PORT=8080
export METRICS_HTTP_PORT=8003
export METRICS_GRPC_PORT=50055
# build the node agent
docker build -f ../star/Dockerfile .. -t star
# start node agents
echo y | rm -r "$(pwd)"/nodeconfig
mkdir "$(pwd)"/nodeconfig
nodes="${NODES_NUM:-2}"
for ((i=1; i<=nodes; i++))
do
echo $i
mkdir "$(pwd)"/nodeconfig/star_"$i"
docker run -d --name star_"$i" \
--mount type=bind,source="$(pwd)"/nodeconfig/star_"$i",target="$NODE_ID_DIR_PATH" \
--env STAR_ADDRESS=:${STAR_PORT} \
--env OORT_ADDRESS=${OORT_HOSTNAME}:${OORT_PORT} \
--env NATS_ADDRESS=${NATS_HOSTNAME}:${NATS_PORT} \
--env REGISTRATION_REQ_TIMEOUT_MILLISECONDS=${REGISTRATION_TIMEOUT} \
--env MAX_REGISTRATION_RETRIES=${MAX_REGISTRATION_RETRIES} \
--env NODE_ID_DIR_PATH=${NODE_ID_DIR_PATH} \
--env NODE_ID_FILE_NAME=${NODE_ID_FILE_NAME} \
--env BIND_ADDRESS=${SERF_BIND_ADDRESS}\
--env BIND_PORT=$((SERF_BIND_PORT + i - 1)) \
--env JOIN_CLUSTER_ADDRESS=${SERF_CLUSTER_ADDRESS} \
--env JOIN_CLUSTER_PORT=${SERF_CLUSTER_PORT} \
--env GOSSIP_TAG=${SERF_GOSSIP_TAG}$i",tag2:val2" \
--env GOSSIP_NODE_NAME=${STAR_HOSTNAME}_$i \
-p $(($STAR_PORT + $i - 1)):${STAR_PORT} \
--hostname "$STAR_HOSTNAME" \
--network=tools_network \
star:latest
done
for ((i=1; i<=nodes; i++))
do
docker run -d \
--name cadvisor_"$i" \
--hostname cadvisor_"$i" \
-p $(($CADVISOR_PORT + $i - 1)):${CADVISOR_INTERNAL_PORT} \
--volume /:/rootfs:ro \
--volume /var/run:/var/run:rw \
--volume /sys:/sys:ro \
--volume /var/lib/docker/:/var/lib/docker:ro \
--volume /var/lib/dbus/machine-id:/var/lib/dbus/machine-id:ro \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--network tools_network \
gcr.io/cadvisor/cadvisor:v0.47.1
done
for ((i=1; i<=nodes; i++))
do
docker run -d \
--name node_exporter_"$i" \
--hostname node_exporter \
-p $(($NODE_EXPORTER_PORT + $i - 1)):9100 \
--network tools_network \
prom/node-exporter
done
docker build -f ../starometry/Dockerfile .. -t starometry
for ((i=1; i<=nodes; i++))
do
docker create \
--name starometry_"$i" \
--hostname starometry \
-p $(($STAROMETRY_HTTP_PORT + $i - 1)):${STAROMETRY_HTTP_PORT} \
-p $(($STAROMETRY_GRPC_PORT + $i - 1)):${STAROMETRY_GRPC_PORT} \
--restart always \
--env NODE_EXPORTER_URL=${NODE_EXPORTER_URL} \
--env NODE_EXPORTER_PORT=9100 \
--env CADVISOR_URL=cadvisor_"$i" \
--env CADVISOR_PORT=${CADVISOR_INTERNAL_PORT} \
--env APP_PORT=${STAROMETRY_HTTP_PORT} \
--env NATS_PORT=${NATS_PORT} \
--env NATS_URL=${NATS_HOSTNAME} \
--env GRPC_PORT=${STAROMETRY_GRPC_PORT} \
--mount type=bind,source="$(pwd)"/nodeconfig/star_"$i",target="$NODE_ID_DIR_PATH" \
--network tools_network \
starometry:latest
docker start starometry_"$i"
done