feat(health-check): add pipeline busy status to health endpoint

This commit is contained in:
yangdx
2025-03-26 12:41:49 +08:00
parent 57143fedcc
commit 1030068459

View File

@@ -421,37 +421,44 @@ def create_app(args):
@app.get("/health", dependencies=[Depends(combined_auth)]) @app.get("/health", dependencies=[Depends(combined_auth)])
async def get_status(): async def get_status():
"""Get current system status""" """Get current system status"""
username = os.getenv("AUTH_USERNAME") try:
password = os.getenv("AUTH_PASSWORD") pipeline_status = await get_namespace_data("pipeline_status")
if not (username and password):
auth_mode = "disabled"
else:
auth_mode = "enabled"
return { username = os.getenv("AUTH_USERNAME")
"status": "healthy", password = os.getenv("AUTH_PASSWORD")
"working_directory": str(args.working_dir), if not (username and password):
"input_directory": str(args.input_dir), auth_mode = "disabled"
"configuration": { else:
# LLM configuration binding/host address (if applicable)/model (if applicable) auth_mode = "enabled"
"llm_binding": args.llm_binding,
"llm_binding_host": args.llm_binding_host, return {
"llm_model": args.llm_model, "status": "healthy",
# embedding model configuration binding/host address (if applicable)/model (if applicable) "working_directory": str(args.working_dir),
"embedding_binding": args.embedding_binding, "input_directory": str(args.input_dir),
"embedding_binding_host": args.embedding_binding_host, "configuration": {
"embedding_model": args.embedding_model, # LLM configuration binding/host address (if applicable)/model (if applicable)
"max_tokens": args.max_tokens, "llm_binding": args.llm_binding,
"kv_storage": args.kv_storage, "llm_binding_host": args.llm_binding_host,
"doc_status_storage": args.doc_status_storage, "llm_model": args.llm_model,
"graph_storage": args.graph_storage, # embedding model configuration binding/host address (if applicable)/model (if applicable)
"vector_storage": args.vector_storage, "embedding_binding": args.embedding_binding,
"enable_llm_cache_for_extract": args.enable_llm_cache_for_extract, "embedding_binding_host": args.embedding_binding_host,
}, "embedding_model": args.embedding_model,
"core_version": core_version, "max_tokens": args.max_tokens,
"api_version": __api_version__, "kv_storage": args.kv_storage,
"auth_mode": auth_mode, "doc_status_storage": args.doc_status_storage,
} "graph_storage": args.graph_storage,
"vector_storage": args.vector_storage,
"enable_llm_cache_for_extract": args.enable_llm_cache_for_extract,
},
"core_version": core_version,
"api_version": __api_version__,
"auth_mode": auth_mode,
"pipeline_busy": pipeline_status.get("busy", False)
}
except Exception as e:
logger.error(f"Error getting health status: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
# Custom StaticFiles class to prevent caching of HTML files # Custom StaticFiles class to prevent caching of HTML files
class NoCacheStaticFiles(StaticFiles): class NoCacheStaticFiles(StaticFiles):