MCPcopy Create free account
hub / github.com/Tong89/smartNode / readiness_probe

Function readiness_probe

backend/api.py:1592–1609  ·  view source on GitHub ↗

就绪探针:仿真线程存活才视为就绪,否则 503。 同时挂载 /api/ready(K8s / Compose 约定俗成的短路径)与 /api/readyz。 校验逻辑:仿真引擎 running 标志为真且后台线程存活,才认为服务就绪。 非就绪时返回 HTTP 503,供 K8s livenessProbe / readinessProbe 与 Alertmanager dead_man_switch 规则使用。

()

Source from the content-addressed store, hash-verified

1590@app.route('/api/readyz')
1591@app.route('/api/ready')
1592def readiness_probe():
1593 """就绪探针:仿真线程存活才视为就绪,否则 503。
1594
1595 同时挂载 /api/ready(K8s / Compose 约定俗成的短路径)与 /api/readyz。
1596 校验逻辑:仿真引擎 running 标志为真且后台线程存活,才认为服务就绪。
1597 非就绪时返回 HTTP 503,供 K8s livenessProbe / readinessProbe 与
1598 Alertmanager dead_man_switch 规则使用。
1599 """
1600 thread = simulation_engine.simulation_thread
1601 thread_alive = bool(thread and thread.is_alive())
1602 ready = bool(simulation_engine.running and thread_alive)
1603 body = {
1604 'status': 'ready' if ready else 'not_ready',
1605 'simulation_running': simulation_engine.running,
1606 'simulation_thread_alive': thread_alive,
1607 'version': __version__,
1608 }
1609 return (jsonify(body), 200) if ready else (jsonify(body), 503)
1610
1611
1612@app.route('/api/quota')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected