yangdx commited on
Commit
d0ba3dc
·
1 Parent(s): 84bb9ab

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

Browse files
Files changed (1) hide show
  1. lightrag/api/lightrag_server.py +37 -30
lightrag/api/lightrag_server.py CHANGED
@@ -421,37 +421,44 @@ def create_app(args):
421
  @app.get("/health", dependencies=[Depends(combined_auth)])
422
  async def get_status():
423
  """Get current system status"""
424
- username = os.getenv("AUTH_USERNAME")
425
- password = os.getenv("AUTH_PASSWORD")
426
- if not (username and password):
427
- auth_mode = "disabled"
428
- else:
429
- auth_mode = "enabled"
 
 
 
430
 
431
- return {
432
- "status": "healthy",
433
- "working_directory": str(args.working_dir),
434
- "input_directory": str(args.input_dir),
435
- "configuration": {
436
- # LLM configuration binding/host address (if applicable)/model (if applicable)
437
- "llm_binding": args.llm_binding,
438
- "llm_binding_host": args.llm_binding_host,
439
- "llm_model": args.llm_model,
440
- # embedding model configuration binding/host address (if applicable)/model (if applicable)
441
- "embedding_binding": args.embedding_binding,
442
- "embedding_binding_host": args.embedding_binding_host,
443
- "embedding_model": args.embedding_model,
444
- "max_tokens": args.max_tokens,
445
- "kv_storage": args.kv_storage,
446
- "doc_status_storage": args.doc_status_storage,
447
- "graph_storage": args.graph_storage,
448
- "vector_storage": args.vector_storage,
449
- "enable_llm_cache_for_extract": args.enable_llm_cache_for_extract,
450
- },
451
- "core_version": core_version,
452
- "api_version": __api_version__,
453
- "auth_mode": auth_mode,
454
- }
 
 
 
 
455
 
456
  # Custom StaticFiles class to prevent caching of HTML files
457
  class NoCacheStaticFiles(StaticFiles):
 
421
  @app.get("/health", dependencies=[Depends(combined_auth)])
422
  async def get_status():
423
  """Get current system status"""
424
+ try:
425
+ pipeline_status = await get_namespace_data("pipeline_status")
426
+
427
+ username = os.getenv("AUTH_USERNAME")
428
+ password = os.getenv("AUTH_PASSWORD")
429
+ if not (username and password):
430
+ auth_mode = "disabled"
431
+ else:
432
+ auth_mode = "enabled"
433
 
434
+ return {
435
+ "status": "healthy",
436
+ "working_directory": str(args.working_dir),
437
+ "input_directory": str(args.input_dir),
438
+ "configuration": {
439
+ # LLM configuration binding/host address (if applicable)/model (if applicable)
440
+ "llm_binding": args.llm_binding,
441
+ "llm_binding_host": args.llm_binding_host,
442
+ "llm_model": args.llm_model,
443
+ # embedding model configuration binding/host address (if applicable)/model (if applicable)
444
+ "embedding_binding": args.embedding_binding,
445
+ "embedding_binding_host": args.embedding_binding_host,
446
+ "embedding_model": args.embedding_model,
447
+ "max_tokens": args.max_tokens,
448
+ "kv_storage": args.kv_storage,
449
+ "doc_status_storage": args.doc_status_storage,
450
+ "graph_storage": args.graph_storage,
451
+ "vector_storage": args.vector_storage,
452
+ "enable_llm_cache_for_extract": args.enable_llm_cache_for_extract,
453
+ },
454
+ "core_version": core_version,
455
+ "api_version": __api_version__,
456
+ "auth_mode": auth_mode,
457
+ "pipeline_busy": pipeline_status.get("busy", False)
458
+ }
459
+ except Exception as e:
460
+ logger.error(f"Error getting health status: {str(e)}")
461
+ raise HTTPException(status_code=500, detail=str(e))
462
 
463
  # Custom StaticFiles class to prevent caching of HTML files
464
  class NoCacheStaticFiles(StaticFiles):