-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmaster.sh
More file actions
executable file
·63 lines (48 loc) · 1.29 KB
/
master.sh
File metadata and controls
executable file
·63 lines (48 loc) · 1.29 KB
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
#!/usr/bin/env bash
set -eo pipefail
fail() {
echo "$@" >&2
exit 1
}
BUILDBOT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "$BUILDBOT_ROOT"
##
# Determine the command to give to the master
command="${1:-}"
shift || true
if [[ -z "$command" ]]; then
if [[ -f master/twistd.pid ]]; then
command="reconfig"
else
command="start"
fi
fi
##
# Check necessary files are present
secrets_dir="${HALIDE_BB_MASTER_SECRETS_DIR:-secrets}"
for secret in buildbot_www_pass github_token halide_bb_pass webhook_token; do
if [ ! -s "$secrets_dir/${secret}.txt" ]; then
fail "Missing or empty $secrets_dir/${secret}.txt: cannot continue"
fi
done
db_url="${HALIDE_BB_MASTER_DB_URL:-sqlite:///state.sqlite}"
if echo "$db_url" | grep -q '{DB_PASSWORD}'; then
if [ ! -s "$secrets_dir/db_password.txt" ]; then
fail "Missing or empty $secrets_dir/db_password.txt: required by HALIDE_BB_MASTER_DB_URL"
fi
fi
##
# Resolve the buildbot command
if command -v buildbot >/dev/null 2>&1; then
run=(buildbot)
else
run=(uv run --package master buildbot)
fi
##
# Run the master
echo "Running buildbot $command master"
# Ensure the master is upgraded before starting
if [[ "$command" == "start" ]]; then
"${run[@]}" upgrade-master master
fi
exec "${run[@]}" "$command" "$@" master