Skip to content

Commit

Permalink
feat: healthz health check
Browse files Browse the repository at this point in the history
  • Loading branch information
WasinUddy committed Nov 20, 2024
1 parent eca747b commit 33ceb7c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [2.0.4] - 2024-11-20
### Added
- Added `/healthz` endpoint to check the health of the server for use in Kubernetes liveness and readiness probes

## [2.0.3] - 2024-11-18
### Added
- Added ability to back up persistent data to AWS S3 compatible storage
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ COPY backend/ /app/
EXPOSE 8000
EXPOSE 19132/udp

# Healthcheck to ensure the container is healthy
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD wget --quiet --tries=1 --spider http://localhost:8000/healthz || exit 1

# Define the entry point for the container
CMD ["python", "main.py"]
CMD ["python", "main.py"]
6 changes: 6 additions & 0 deletions backend/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ async def save_data():
except Exception as e:
logging.error(f"Error saving data: {e}")
raise HTTPException(status_code=500, detail=str(e))


# Health check liveliness and readiness probe for k8s compatibility
@app.get('/healthz')
async def health_check():
return {'status': 'ok'}


# WebSocket endpoint for data streaming
Expand Down

0 comments on commit 33ceb7c

Please sign in to comment.