lukhsaankumar commited on
Commit
e480039
·
1 Parent(s): f2c511a

Deploy DeepFake Detector API - 2026-04-21 00:58:45

Browse files
Files changed (2) hide show
  1. app/scripts/run_server.py +40 -0
  2. start.sh +2 -2
app/scripts/run_server.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Runtime launcher with extra startup timing for container boot analysis."""
2
+
3
+ import os
4
+ import time
5
+ from datetime import datetime, timezone
6
+
7
+ from app.core.config import settings
8
+
9
+
10
+ START_T0 = time.perf_counter()
11
+
12
+
13
+ def _log(message: str) -> None:
14
+ print(
15
+ f"{datetime.now(timezone.utc).isoformat()} | INFO | app.scripts.run_server | {message}",
16
+ flush=True,
17
+ )
18
+
19
+
20
+ def main() -> None:
21
+ port = os.environ.get("PORT", str(settings.PORT))
22
+ _log(f"launcher_start port={port} host={settings.HOST}")
23
+
24
+ import uvicorn
25
+
26
+ _log(f"uvicorn_import_complete duration_seconds={time.perf_counter() - START_T0:.3f}")
27
+ _log(
28
+ f"calling_uvicorn_run app=app.main:app host={settings.HOST} port={port} reload={settings.ENABLE_DEBUG}"
29
+ )
30
+ uvicorn.run(
31
+ "app.main:app",
32
+ host=settings.HOST,
33
+ port=int(port),
34
+ reload=settings.ENABLE_DEBUG,
35
+ log_level="info",
36
+ )
37
+
38
+
39
+ if __name__ == "__main__":
40
+ main()
start.sh CHANGED
@@ -33,5 +33,5 @@ mkdir -p "$HF_HOME" "$HF_CACHE_DIR" 2>/dev/null || true
33
  echo "Using HF cache dir: $HF_CACHE_DIR"
34
  echo "Using HF home dir: $HF_HOME"
35
 
36
- echo "Starting uvicorn on port $PORT"
37
- exec uvicorn app.main:app --host 0.0.0.0 --port "$PORT" --log-level info
 
33
  echo "Using HF cache dir: $HF_CACHE_DIR"
34
  echo "Using HF home dir: $HF_HOME"
35
 
36
+ echo "Starting uvicorn launcher on port $PORT"
37
+ exec python -m app.scripts.run_server