This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathall_live.sh
executable file
·98 lines (83 loc) · 2.33 KB
/
all_live.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
#!/usr/bin/env bash
# Copyright © 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
# Copyright © 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache License 2.0
set -e
set -o pipefail
SETUP_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
--no-workers) WORKERS=false; shift;; # disable qworkers
--no-api) API=false; shift;; # disable the api
--no-web) WEB=false; shift;; # disable the web
--api-only) WEB=false; WORKERS=false; shift;; # only run api containers
--web-only) API=false; WORKERS=false; shift;; # only run web containers
--foreground) FOREGROUND=true; shift;;
--documentation) DOCUMENTATION=true; shift;;
*) SETUP_ARGS+=("$1"); shift;;
esac
done
FOREGROUND_SERVICES=(protowatch nginx)
BACKGROUND_SERVICES=()
if "${WORKERS:-true}"; then
FOREGROUND_SERVICES+=(qworker qworker-analytics)
fi
if "${API:-true}"; then
FOREGROUND_SERVICES+=(api smtp)
fi
if "${WEB:-true}"; then
FOREGROUND_SERVICES+=(web-client web-server)
fi
if "${FOREGROUND:-false}"; then
FOREGROUND_SERVICES+=("${BACKGROUND_SERVICES[@]}")
BACKGROUND_SERVICES=()
fi
if "${DOCUMENTATION:-false}"; then
FOREGROUND_SERVICES=(documentation)
BACKGROUND_SERVICES=()
fi
if [ ${#FOREGROUND_SERVICES[@]} -eq 0 ]; then
>&2 echo "No services to launch in the foreground!"
exit 1
fi
function setup_web {
if "${WEB:-true}"; then
./scripts/launch/compose.sh run --rm init-web
fi
}
function kill_services {
./scripts/launch/compose.sh kill \
"${FOREGROUND_SERVICES[@]}" \
"${BACKGROUND_SERVICES[@]}" &>/dev/null || true
}
function start_bg_services {
if [ ${#BACKGROUND_SERVICES[@]} -gt 0 ]; then
./scripts/launch/compose.sh build "${BACKGROUND_SERVICES[@]}"
if [ -n "$BUILD_ONLY" ]; then
return
fi
./scripts/launch/compose.sh up --detach "${BACKGROUND_SERVICES[@]}"
fi
}
function start_fg_services {
if [ ${#FOREGROUND_SERVICES[@]} -gt 0 ]; then
./scripts/launch/compose.sh build "${FOREGROUND_SERVICES[@]}"
if [ -n "$BUILD_ONLY" ]; then
return
fi
./scripts/launch/compose.sh up -d "${FOREGROUND_SERVICES[@]}"
./scripts/launch/compose.sh logs -f "${FOREGROUND_SERVICES[@]}"
fi
}
function main {
. scripts/launch/setup_env.sh "$@"
setup_web
kill_services
start_bg_services
trap kill_services EXIT
start_fg_services
}
main "${SETUP_ARGS[@]}"