MikelWL commited on
Commit
157ea23
·
1 Parent(s): f84f9af

HF Spaces: run app in foreground (exec)

Browse files
Files changed (1) hide show
  1. start_hf_space.sh +4 -29
start_hf_space.sh CHANGED
@@ -3,36 +3,11 @@ set -eu
3
 
4
  ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
 
6
- : "${API_HOST:=0.0.0.0}"
7
  : "${PORT:=7860}"
8
- : "${LOG_LEVEL:=info}"
9
 
10
- echo "Starting frontend (React hybrid) on 0.0.0.0:${PORT} ..."
11
- (
12
- cd "${ROOT_DIR}"
13
- PORT="${PORT}" python frontend/react_gradio_hybrid.py
14
- ) > /tmp/frontend.log 2>&1 &
15
- FRONTEND_PID=$!
16
 
17
- cleanup() {
18
- echo "Shutting down..."
19
- kill "${FRONTEND_PID}" 2>/dev/null || true
20
- }
21
 
22
- trap cleanup INT TERM EXIT
23
-
24
- sleep 0.5
25
- if ! kill -0 "${FRONTEND_PID}" 2>/dev/null; then
26
- echo "Frontend failed to start. Logs:"
27
- cat /tmp/frontend.log || true
28
- exit 1
29
- fi
30
-
31
- (
32
- wait "${FRONTEND_PID}" 2>/dev/null || true
33
- echo "Frontend exited"
34
- echo "Frontend logs:"
35
- cat /tmp/frontend.log || true
36
- ) &
37
-
38
- wait "${FRONTEND_PID}" 2>/dev/null || true
 
3
 
4
  ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
 
 
6
  : "${PORT:=7860}"
 
7
 
8
+ echo "===== Application Startup at $(date -u '+%Y-%m-%d %H:%M:%S') ====="
9
+ echo "Starting app on 0.0.0.0:${PORT} ..."
 
 
 
 
10
 
11
+ cd "${ROOT_DIR}"
12
+ exec env PORT="${PORT}" python -u frontend/react_gradio_hybrid.py
 
 
13