-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·87 lines (72 loc) · 1.41 KB
/
entrypoint.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
#!/usr/bin/env bash
set -e
set -x
: "${WAIT_GATEWAYS:?}"
print_section () {
echo
echo "###" $1
echo
}
wait_init () {
print_section "Waiting for base services"
wotemu wait --waiter-base
}
wait_gateways () {
print_section "Waiting for gateways (${WAIT_GATEWAYS}s)"
sleep ${WAIT_GATEWAYS}
}
wait_brokers () {
print_section "Waiting for MQTT brokers"
wotemu wait --waiter-mqtt
}
update_routing () {
print_section "Updating routing configuration"
wotemu route --apply
}
update_cpu_limits() {
if [ -z "$TARGET_CPU_SPEED" ]
then
print_section "Ignoring CPU limits due to undefined speed variable"
return
fi
print_section "Updating CPU limits to match speed: ${TARGET_CPU_SPEED}"
wotemu limits --speed ${TARGET_CPU_SPEED}
}
run_app () {
exec wotemu app "$@"
}
run_mqtt_broker () {
exec wotemu broker
}
run_chaos () {
args=()
for var in "$@"
do
args+=(--netem "${var}")
done
exec wotemu chaos "${args[@]}"
}
case "$1" in
app)
wait_init
wait_gateways
update_routing
wait_brokers
update_cpu_limits
run_app "${@:2}"
;;
broker)
wait_init
wait_gateways
update_routing
update_cpu_limits
run_mqtt_broker
;;
gateway)
wait_init
run_chaos "${@:2}"
;;
*)
exec "$@"
;;
esac