mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-11 07:16:27 +00:00
385daf16be
* on_chain/group_manager: use .async: (raises:[Exception]). * bump nim-dnsdisc * update nim-chronos to the latest state * chat2.nim: catch any possible exception when stopping * chat2bridge.nim: make it to compile after vendor bump * ValidIpAddress (deprecated) -> IpAddress * vendor/nim-libp2p additional bump * libwaku: adapt to vendor bump * testlib/wakunode.nim: adapt to vendor bump (ValidIpAddress -> IpAddress) * waku_node: avoid throwing any exception from stop*(node: WakuNode) * test_confutils_envvar.nim: ValidIpAddress -> IpAddress * test_jsonrpc_store: capture exception * test_rln*: handling exceptions * adaptation to make test_rln_* to work properly * signature enhancement of group_manager methods
47 lines
1.3 KiB
Nim
47 lines
1.3 KiB
Nim
when (NimMajor, NimMinor) < (1, 4):
|
|
{.push raises: [Defect].}
|
|
else:
|
|
{.push raises: [].}
|
|
|
|
import
|
|
chronicles,
|
|
json_serialization,
|
|
presto/route
|
|
import
|
|
../../../waku_node,
|
|
../responses,
|
|
../serdes
|
|
|
|
logScope:
|
|
topics = "waku node rest health_api"
|
|
|
|
const ROUTE_HEALTH* = "/health"
|
|
|
|
const FutIsReadyTimout = 5.seconds
|
|
|
|
proc installHealthApiHandler*(router: var RestRouter, node: WakuNode) =
|
|
## /health endpoint provides information about node readiness to caller.
|
|
## Currently it is restricted to checking RLN (if mounted) proper setup
|
|
## TODO: Leter to extend it to a broader information about each subsystem state
|
|
## report. Rest response to change to JSON structure that can hold exact detailed
|
|
## information.
|
|
|
|
router.api(MethodGet, ROUTE_HEALTH) do () -> RestApiResponse:
|
|
|
|
let isReadyStateFut = node.isReady()
|
|
if not await isReadyStateFut.withTimeout(FutIsReadyTimout):
|
|
return RestApiResponse.internalServerError("Health check timed out")
|
|
|
|
var msg = "Node is healthy"
|
|
var status = Http200
|
|
|
|
try:
|
|
if not isReadyStateFut.read():
|
|
msg = "Node is not ready"
|
|
status = Http503
|
|
except:
|
|
msg = "exception reading state: " & getCurrentExceptionMsg()
|
|
status = Http500
|
|
|
|
return RestApiResponse.textResponse(msg, status)
|