Compare commits

...

3 Commits

Author SHA1 Message Date
Ivan Folgueira Bande
c483ba86fc more temporary logs 2025-05-30 21:51:09 +02:00
Ivan Folgueira Bande
2b5836627a adding temporary debug logs 2025-05-30 20:02:10 +02:00
Ivan Folgueira Bande
1b5bc2da5e switch add more error detail in start 2025-05-30 19:56:27 +02:00
3 changed files with 20 additions and 10 deletions

View File

@@ -13,7 +13,7 @@
{.push raises: [].}
import std/[tables, options, sequtils, sets, oids]
import std/[tables, options, sequtils, sets, oids], typetraits
import chronos, chronicles, metrics
@@ -82,6 +82,7 @@ method run*(self: Service, switch: Switch) {.base, async: (raises: [CancelledErr
method stop*(
self: Service, switch: Switch
): Future[bool] {.base, async: (raises: [CancelledError]).} =
debug "Stopping service", service = name(typeof(self))
if not self.inUse:
warn "service is already stopped"
return false
@@ -315,7 +316,7 @@ proc stop*(s: Switch) {.public, async: (raises: [CancelledError]).} =
# Stop accepting incoming connections
await allFutures(s.acceptFuts.mapIt(it.cancelAndWait())).wait(1.seconds)
except CatchableError as exc:
debug "Cannot cancel accepts", description = exc.msg
error "Cannot cancel accepts", description = exc.msg
for service in s.services:
discard await service.stop(s)
@@ -325,11 +326,13 @@ proc stop*(s: Switch) {.public, async: (raises: [CancelledError]).} =
for transp in s.transports:
try:
debug "Stopping transport", transport = name(typeof(transp))
await transp.stop()
except CancelledError as exc:
error "Cancelled while stopping transport", error = exc.msg
raise exc
except CatchableError as exc:
warn "error cleaning up transports", description = exc.msg
error "error cleaning up transports", description = exc.msg
await s.ms.stop()
@@ -350,13 +353,20 @@ proc start*(s: Switch) {.public, async: (raises: [CancelledError, LPError]).} =
s.peerInfo.listenAddrs.keepItIf(it notin addrs)
if addrs.len > 0 or t.running:
let fut = t.start(addrs)
debug "Starting transport",
transport = name(typeof(t)), addrs = addrs, future = name(typeof(fut))
startFuts.add(t.start(addrs))
await allFutures(startFuts)
debug "Switch after starting transports"
for fut in startFuts:
if fut.failed:
await s.stop()
error "Failed to start transport",
future = name(typeof(fut)), error = fut.error.msg
raise newException(LPError, "starting transports failed", fut.error)
for t in s.transports: # for each transport

View File

@@ -115,7 +115,7 @@ method start*(
warn "TCP transport already running"
return
trace "Starting TCP transport"
debug "Starting TCP transport"
self.flags.incl(ServerFlags.ReusePort)
@@ -137,7 +137,7 @@ method start*(
self.servers &= server
trace "Listening on", address = ma
debug "Listening on", address = ma
supported.add(
MultiAddress.init(server.sock.getLocalAddress()).expect(
"Can init from local address"
@@ -156,7 +156,7 @@ method start*(
trackCounter(TcpTransportTrackerName)
method stop*(self: TcpTransport): Future[void] {.async: (raises: []).} =
trace "Stopping TCP transport"
debug "Stopping TCP transport"
self.stopping = true
defer:
self.stopping = false
@@ -186,7 +186,7 @@ method stop*(self: TcpTransport): Future[void] {.async: (raises: []).} =
warn "Couldn't clean up clients",
len = self.clients[Direction.In].len + self.clients[Direction.Out].len
trace "Transport stopped"
debug "Transport stopped"
untrackCounter(TcpTransportTrackerName)
else:
# For legacy reasons, `stop` on a transpart that wasn't started is

View File

@@ -188,7 +188,7 @@ method stop*(self: WsTransport) {.async: (raises: []).} =
self.running = false # mark stopped as soon as possible
try:
trace "Stopping WS transport"
debug "Stopping WS transport"
await procCall Transport(self).stop() # call base
checkFutures(
@@ -212,9 +212,9 @@ method stop*(self: WsTransport) {.async: (raises: []).} =
await allFutures(toWait)
self.httpservers = @[]
trace "Transport stopped"
debug "Transport stopped"
except CatchableError as exc:
trace "Error shutting down ws transport", description = exc.msg
error "Error shutting down ws transport", description = exc.msg
proc connHandler(
self: WsTransport, stream: WSSession, secure: bool, dir: Direction