Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

105 Zeilen
3.7KB

  1. <%
  2. ' ApiHealthController: liveness and readiness probes (spec 9, health). No authentication, no tenant data.
  3. '
  4. ' GET /api/v1/health/live Live 200 while the process answers
  5. ' GET /api/v1/health/ready Ready 200 when the database answers (status ready, or degraded when the embedding
  6. ' provider / vector store is unreachable), else 503
  7. Class ApiHealthController_Class
  8. Public Property Get useLayout()
  9. useLayout = False
  10. End Property
  11. Public Property Let useLayout(v)
  12. End Property
  13. Public Property Get Title()
  14. Title = "Health"
  15. End Property
  16. Public Sub Live()
  17. Api_Send 200, "{""status"":""live""}"
  18. End Sub
  19. ' 503 only when the database is down. Semantic retrieval is optional (lexical keeps working), so an unreachable
  20. ' embedding provider or vector store gives 200 with status "degraded". Counts only, no tenant data.
  21. Public Sub Ready()
  22. Dim rs, ok, emb, store, pending, failed, status, resp, st
  23. ok = False
  24. pending = 0
  25. failed = 0
  26. On Error Resume Next
  27. Set rs = DAL().Query("SELECT 1", Empty)
  28. If Err.Number = 0 Then
  29. ok = Not rs.EOF
  30. rs.Close
  31. End If
  32. Err.Clear
  33. If ok Then
  34. Set rs = DAL().Query("SELECT SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END), SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) FROM embedding_index", Empty)
  35. If Err.Number = 0 Then
  36. If Not rs.EOF Then
  37. If Not IsNull(rs(0)) Then
  38. pending = CLng(rs(0))
  39. failed = CLng(rs(1))
  40. End If
  41. End If
  42. rs.Close
  43. End If
  44. Err.Clear
  45. End If
  46. On Error GoTo 0
  47. If Not ok Then
  48. Api_Send 503, "{""status"":""unavailable"",""checks"":{""database"":""down""}}"
  49. Exit Sub
  50. End If
  51. status = "ready"
  52. If Emb_Enabled() Then
  53. resp = Emb_Http("GET", Emb_Setting("EmbeddingUrl", "http://ollama:11434") & "/api/version", "", st)
  54. If st = 200 Then
  55. emb = "up"
  56. Else
  57. emb = "down"
  58. status = "degraded"
  59. End If
  60. resp = Emb_Http("GET", Emb_Setting("VectorStoreUrl", "http://qdrant:6333") & "/readyz", "", st)
  61. If st = 200 Then
  62. store = "up"
  63. Else
  64. store = "down"
  65. status = "degraded"
  66. End If
  67. Else
  68. emb = "disabled"
  69. store = "disabled"
  70. End If
  71. Api_Send 200, "{""status"":""" & status & """,""checks"":{""database"":""up"",""embeddings"":""" & emb & """,""vector_store"":""" & store & """}" & _
  72. ",""embedding_backlog"":{""pending"":" & pending & ",""failed"":" & failed & "}}"
  73. End Sub
  74. ' Static action dispatch (AxonASP mishandles runtime-built Eval/Execute calls and shared call sites)
  75. Public Sub Invoke(actionName, args)
  76. Select Case LCase(actionName)
  77. Case "live" : Live
  78. Case "ready" : Ready
  79. Case Else
  80. Err.Raise 438, "ApiHealthController_Class", "Action '" & actionName & "' not found"
  81. End Select
  82. End Sub
  83. End Class
  84. Dim ApiHealthController_Class__Singleton
  85. Function ApiHealthController()
  86. If IsEmpty(ApiHealthController_Class__Singleton) Then
  87. Set ApiHealthController_Class__Singleton = New ApiHealthController_Class
  88. End If
  89. Set ApiHealthController = ApiHealthController_Class__Singleton
  90. End Function
  91. ' Global entry point used by MVC_InvokeAction via GetRef (one call site per controller)
  92. Sub ApiHealthController_Invoke(actionName, args)
  93. ApiHealthController().Invoke actionName, args
  94. End Sub
  95. %>

Powered by TurnKey Linux.