This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
44 lines (37 loc) · 1.59 KB
/
start.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
#!/bin/bash
set -e
########################
# Wait for service to be ready
# Globals: none
# Arguments: name host port
# Returns: none
#########################
wait_for_service() {
local service_name="$1"
local service_host="$2"
local service_port="$3"
local service_address=$(getent hosts "$service_host" | awk '{ print $1 }')
counter=0
echo "Connecting to $service_name at $service_address"
while ! nc -z "$service_address" "$service_port" >/dev/null; do
counter=$((counter+1))
if [ $counter == 30 ]; then
echo "Error: Couldn't connect to $service_name at $service_address."
exit 1
fi
echo "Trying to connect to $service_name at $service_address. Attempt $counter."
sleep 5
done
}
# Functions for running Epsilon
java -cp target/org.eclipse.epsilon.playground.jar com.google.cloud.functions.invoker.runner.Invoker --target org.eclipse.epsilon.playground.RunEpsilonFunction --port 8001 &
wait_for_service Epsilon 127.0.0.1 8001
java -cp target/org.eclipse.epsilon.playground.jar com.google.cloud.functions.invoker.runner.Invoker --target org.eclipse.epsilon.playground.FlexmiToPlantUMLFunction --port 8002 &
wait_for_service Flexmi 127.0.0.1 8002
java -cp target/org.eclipse.epsilon.playground.jar com.google.cloud.functions.invoker.runner.Invoker --target org.eclipse.epsilon.playground.EmfaticToPlantUMLFunction --port 8003 &
wait_for_service Emfatic 127.0.0.1 8003
# nginx as frontend + reverse proxy
envsubst < /etc/nginx.conf.template > /etc/nginx/conf.d/default.conf
nginx -g "daemon off;" &
# wait for them all
wait -n