Skip to content

add health method#984

Merged
helloyongyang merged 1 commit intomainfrom
feat-server
Apr 2, 2026
Merged

add health method#984
helloyongyang merged 1 commit intomainfrom
feat-server

Conversation

@black-eleven
Copy link
Copy Markdown
Contributor

No description provided.

@helloyongyang helloyongyang merged commit 53ecbee into main Apr 2, 2026
2 checks passed
@helloyongyang helloyongyang deleted the feat-server branch April 2, 2026 03:17
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new /health endpoint to the server. The review suggests upgrading this to a 'deep' health check that monitors the background processing thread and task manager status, while also recommending the use of 'async def' for the endpoint to improve performance.

Comment on lines +32 to +34
@self.app.get("/health")
def health_check():
return {"status": "ok"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current health check is 'shallow' and only returns a static 'ok' status. In a distributed system with background workers, it is a best practice to provide a 'deep' health check that reflects the actual state of the service, such as whether the background processing thread is alive and the current status of the task queue. Additionally, using async def is preferred for simple endpoints in FastAPI to avoid the overhead of the external thread pool.

Suggested change
@self.app.get("/health")
def health_check():
return {"status": "ok"}
@self.app.get("/health")
async def health_check():
# Check if the background processing thread is still running
is_alive = self.processing_thread is not None and self.processing_thread.is_alive()
return {
"status": "ok" if is_alive or self.processing_thread is None else "unhealthy",
"worker_alive": is_alive,
**task_manager.get_service_status()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants