Skip to content

Commit 0b54a8e

Browse files
authored
box: Only run frontend on demand and fix shutdown (#3780)
* box: Fix frontend launch It should not be triggered by docker only if you ask frontend * Reapply "Make sure box gracefully shuts down" This reverts commit 7e0038f4aef99c06726d733a027876c54e0194f2.
1 parent 0c30b8c commit 0b54a8e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

box/box.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
#!/bin/bash
22
set -e
33

4+
DOCKER=${DOCKER:-false}
45
FRONTEND=${FRONTEND:-false}
56

7+
if [ "$FRONTEND" = "true" && "$DOCKER" = "false" ]; then
8+
echo "Running the box with FRONTEND=true requires DOCKER=true"
9+
exit 1
10+
fi
11+
12+
# Ensure backgrounded services are stopped gracefully when this script is interrupted or exits.
13+
cleanup() {
14+
if [ "$DOCKER" = "true" ]; then
15+
echo "Stopping dockerized services..."
16+
docker stop orchestrator --time 15 >/dev/null 2>&1 || true
17+
docker stop gateway --time 15 >/dev/null 2>&1 || true
18+
docker stop mediamtx --time 15 >/dev/null 2>&1 || true
19+
fi
20+
}
21+
trap cleanup INT TERM HUP EXIT
22+
623
# Start multiple processes and output their logs to the console
724
gateway() {
825
echo "Starting Gateway..."
@@ -34,9 +51,9 @@ gateway &
3451
orchestrator &
3552
mediamtx &
3653

37-
if [ "$DOCKER" = "true" ]; then
54+
if [ "$FRONTEND" = "true" ]; then
3855
supabase &
39-
mediamtx &
56+
frontend &
4057
fi
4158

4259
# Wait for all background processes to finish

0 commit comments

Comments
 (0)