Skip to content

Commit

Permalink
Added health router and also updated the guthub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilRaikar17 committed Aug 4, 2024
1 parent 4fa9824 commit 1d1a0e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ jobs:
nohup uvicorn main:app --host 0.0.0.0 --port 8000 > /dev/null 2>&1 &
sleep 10
- name: Check FastAPI docs endpoint
- name: Check FastAPI /health endpoint
run: |
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000/docs | grep "200"
response=$(curl -s http://127.0.0.1:8000/health)
echo "Response: $response"
if [ "$response" == '{"status":"active"}' ]; then
echo "Health check passed"
else
echo "Health check failed"
exit 1
fi
- name: Kill FastAPI process
run: |
Expand Down
9 changes: 9 additions & 0 deletions backend/api/health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

from fastapi import APIRouter

health_router = APIRouter()


@health_router.get("/health")
async def check_health():
return {"status": "Active"}
5 changes: 2 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from backend.api.health import health_router
from backend.api.user import user_router
from backend.api.token import token_router
from backend.api.query import query_router
Expand All @@ -17,10 +18,8 @@
allow_headers=["*"],
)

app.include_router(health_router)
app.include_router(token_router)
app.include_router(user_router)
app.include_router(query_router)
populate_admin_user()



0 comments on commit 1d1a0e8

Please sign in to comment.