Spaces:
Runtime error
Runtime error
Commit ·
c2aa6bc
1
Parent(s): 029948d
Add health server so HF marks worker healthy
Browse files- Dockerfile +1 -1
- health_api.py +11 -0
- requirements.txt +2 -0
- start.sh +4 -0
Dockerfile
CHANGED
|
@@ -8,4 +8,4 @@ COPY requirements.txt /app/requirements.txt
|
|
| 8 |
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 9 |
|
| 10 |
COPY . /app
|
| 11 |
-
CMD ["
|
|
|
|
| 8 |
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 9 |
|
| 10 |
COPY . /app
|
| 11 |
+
CMD ["sh","-lc","set -e; python -u backend/worker/worker.py & exec uvicorn health_api:app --host 0.0.0.0 --port "]
|
health_api.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
|
| 3 |
+
app = FastAPI()
|
| 4 |
+
|
| 5 |
+
@app.get("/")
|
| 6 |
+
def root():
|
| 7 |
+
return {"ok": True}
|
| 8 |
+
|
| 9 |
+
@app.get("/health")
|
| 10 |
+
def health():
|
| 11 |
+
return {"ok": True}
|
requirements.txt
CHANGED
|
@@ -10,3 +10,5 @@ Pillow>=10.0.0
|
|
| 10 |
openai>=1.0.0
|
| 11 |
|
| 12 |
PyMuPDF>=1.23.0
|
|
|
|
|
|
|
|
|
| 10 |
openai>=1.0.0
|
| 11 |
|
| 12 |
PyMuPDF>=1.23.0
|
| 13 |
+
fastapi==0.128.0
|
| 14 |
+
uvicorn==0.40.0
|
start.sh
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
python -u backend/worker/worker.py &
|
| 4 |
+
exec uvicorn health_api:app --host 0.0.0.0 --port "${PORT:-7860}"
|