-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·70 lines (60 loc) · 1.32 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·70 lines (60 loc) · 1.32 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
64
65
66
67
68
69
70
#!/usr/bin/env sh
set -eu
APP_MODE="${APP_MODE:-server}"
APP_HOST="${APP_HOST:-0.0.0.0}"
APP_PORT="${APP_PORT:-8000}"
child_pid=""
forward_signal() {
signal="$1"
if [ -n "${child_pid}" ] && kill -0 "${child_pid}" 2>/dev/null; then
kill "-${signal}" "${child_pid}" 2>/dev/null || true
wait "${child_pid}" || true
fi
}
on_sigterm() {
echo "[entrypoint] SIGTERM received. shutting down..."
forward_signal TERM
exit 143
}
on_sigint() {
echo "[entrypoint] SIGINT received. shutting down..."
forward_signal INT
exit 130
}
trap on_sigterm TERM
trap on_sigint INT
run_bg_and_wait() {
"$@" &
child_pid=$!
wait "${child_pid}"
status=$?
child_pid=""
return "${status}"
}
run_server() {
echo "[entrypoint] APP_MODE=${APP_MODE} -> starting unified intelligence server"
run_bg_and_wait uvicorn app.realtime.main:app --host "${APP_HOST}" --port "${APP_PORT}"
}
run_batch() {
echo "[entrypoint] APP_MODE=batch -> running one-off batch"
run_bg_and_wait python -m app.batch.main
echo "[entrypoint] batch completed."
}
case "${APP_MODE}" in
server)
run_server
;;
realtime)
run_server
;;
analysis-server)
run_server
;;
batch)
run_batch
;;
*)
echo "[entrypoint] Unknown APP_MODE: ${APP_MODE} (allowed: server|realtime|analysis-server|batch)"
exit 2
;;
esac