diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 4477352b..27901fb5 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -421,37 +421,44 @@ def create_app(args): @app.get("/health", dependencies=[Depends(combined_auth)]) async def get_status(): """Get current system status""" - username = os.getenv("AUTH_USERNAME") - password = os.getenv("AUTH_PASSWORD") - if not (username and password): - auth_mode = "disabled" - else: - auth_mode = "enabled" + try: + pipeline_status = await get_namespace_data("pipeline_status") + + username = os.getenv("AUTH_USERNAME") + password = os.getenv("AUTH_PASSWORD") + if not (username and password): + auth_mode = "disabled" + else: + auth_mode = "enabled" - return { - "status": "healthy", - "working_directory": str(args.working_dir), - "input_directory": str(args.input_dir), - "configuration": { - # LLM configuration binding/host address (if applicable)/model (if applicable) - "llm_binding": args.llm_binding, - "llm_binding_host": args.llm_binding_host, - "llm_model": args.llm_model, - # embedding model configuration binding/host address (if applicable)/model (if applicable) - "embedding_binding": args.embedding_binding, - "embedding_binding_host": args.embedding_binding_host, - "embedding_model": args.embedding_model, - "max_tokens": args.max_tokens, - "kv_storage": args.kv_storage, - "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, - } + return { + "status": "healthy", + "working_directory": str(args.working_dir), + "input_directory": str(args.input_dir), + "configuration": { + # LLM configuration binding/host address (if applicable)/model (if applicable) + "llm_binding": args.llm_binding, + "llm_binding_host": args.llm_binding_host, + "llm_model": args.llm_model, + # embedding model configuration binding/host address (if applicable)/model (if applicable) + "embedding_binding": args.embedding_binding, + "embedding_binding_host": args.embedding_binding_host, + "embedding_model": args.embedding_model, + "max_tokens": args.max_tokens, + "kv_storage": args.kv_storage, + "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 class NoCacheStaticFiles(StaticFiles):