Álvaro Valenzuela Valdes commited on
Commit
3bce16c
·
1 Parent(s): 4aa8855

fix: conditional backend-only mode and robust health check with retries

Browse files
Files changed (2) hide show
  1. frontend/app/page.tsx +8 -2
  2. start.sh +16 -12
frontend/app/page.tsx CHANGED
@@ -102,11 +102,17 @@ export default function HomePage() {
102
  }
103
  }
104
 
105
- async function init() {
106
  try {
107
  await healthCheck();
108
  setStatus("connected");
109
- } catch {
 
 
 
 
 
 
110
  setStatus("offline");
111
  }
112
 
 
102
  }
103
  }
104
 
105
+ async function init(retries = 3) {
106
  try {
107
  await healthCheck();
108
  setStatus("connected");
109
+ } catch (e) {
110
+ console.error("Connection attempt failed", e);
111
+ if (retries > 0) {
112
+ setStatus("listening"); // Show trying state
113
+ setTimeout(() => init(retries - 1), 3000);
114
+ return;
115
+ }
116
  setStatus("offline");
117
  }
118
 
start.sh CHANGED
@@ -1,14 +1,18 @@
1
  #!/bin/bash
2
- # Trigger build: 2026-05-07 08:42
3
 
4
- # Start Backend
5
- echo "Starting Backend..."
6
- cd /app/backend && uvicorn app.main:app --host 0.0.0.0 --port 8000 &
7
-
8
- # Start Frontend
9
- echo "Starting Frontend..."
10
- cd /app/frontend && npm run start -- -p 3000 &
11
-
12
- # Start Nginx
13
- echo "Starting Nginx..."
14
- nginx -g "daemon off;"
 
 
 
 
 
1
  #!/bin/bash
2
+ # Trigger build: 2026-05-07 08:49
3
 
4
+ if [ "$SERVICE_TYPE" = "backend" ]; then
5
+ echo "!!! STARTING IN BACKEND-ONLY MODE !!!"
6
+ cd /app/backend && uvicorn app.main:app --host 0.0.0.0 --port 7860
7
+ else
8
+ echo "!!! STARTING IN FULL-STACK MODE !!!"
9
+ # Start Backend on internal port
10
+ cd /app/backend && uvicorn app.main:app --host 0.0.0.0 --port 8000 &
11
+
12
+ # Start Frontend on internal port
13
+ cd /app/frontend && npm run start -- -p 3000 &
14
+
15
+ # Start Nginx as the main entry point on HF port 7860
16
+ echo "Starting Nginx Proxy..."
17
+ nginx -g "daemon off;"
18
+ fi