diff --git a/dagger/node.nim b/dagger/node.nim index eb849f33..329b14fb 100644 --- a/dagger/node.nim +++ b/dagger/node.nim @@ -44,10 +44,17 @@ type discovery*: Discovery proc start*(node: DaggerNodeRef) {.async.} = - await node.switch.start() - await node.engine.start() - await node.erasure.start() - await node.discovery.start() + if not node.switch.isNil: + await node.switch.start() + + if not node.engine.isNil: + await node.engine.start() + + if not node.erasure.isNil: + await node.erasure.start() + + if not node.discovery.isNil: + await node.discovery.start() node.networkId = node.switch.peerInfo.peerId notice "Started dagger node", id = $node.networkId, addrs = node.switch.peerInfo.addrs @@ -55,10 +62,17 @@ proc start*(node: DaggerNodeRef) {.async.} = proc stop*(node: DaggerNodeRef) {.async.} = trace "Stopping node" - await node.engine.stop() - await node.switch.stop() - await node.erasure.stop() - await node.discovery.stop() + if not node.engine.isNil: + await node.engine.stop() + + if not node.switch.isNil: + await node.switch.stop() + + if not node.erasure.isNil: + await node.erasure.stop() + + if not node.discovery.isNil: + await node.discovery.stop() proc findPeer*( node: DaggerNodeRef,