chore: guarding against double starting and stopping of nodes (#3525)

This commit is contained in:
gabrielmer 2025-07-24 14:10:13 +02:00 committed by GitHub
parent 184cc4a694
commit b6855e85ab

View File

@ -362,6 +362,10 @@ proc startDnsDiscoveryRetryLoop(waku: ptr Waku): Future[void] {.async.} =
return
proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async.} =
if waku[].node.started:
warn "startWaku: waku node already started"
return ok()
debug "Retrieve dynamic bootstrap nodes"
let conf = waku[].conf
@ -442,6 +446,9 @@ proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async.} =
proc stop*(waku: Waku): Future[void] {.async: (raises: [Exception]).} =
## Waku shutdown
if not waku.node.started:
warn "stop: attempting to stop node that isn't running"
waku.healthMonitor.setOverallHealth(HealthStatus.SHUTTING_DOWN)
if not waku.metricsServer.isNil():