mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-25 22:13:12 +00:00
Implement graceful shutdown for wakunode2 and chat2 (#490)
* Implement graceful shutdown * Consistent use of QuitSuccess
This commit is contained in:
@@ -30,6 +30,7 @@ const Help = """
|
||||
help: Prints this help
|
||||
connect: dials a remote peer
|
||||
nick: change nickname for current chat session
|
||||
exit: exits chat session
|
||||
"""
|
||||
|
||||
const
|
||||
@@ -203,14 +204,11 @@ proc writeAndPrint(c: Chat) {.async.} =
|
||||
c.nick = await readNick(c.transp)
|
||||
echo "You are now known as " & c.nick
|
||||
|
||||
# elif line.startsWith("/exit"):
|
||||
# if p.connected and p.conn.closed.not:
|
||||
# await p.conn.close()
|
||||
# p.connected = false
|
||||
#
|
||||
# await p.switch.stop()
|
||||
# echo "quitting..."
|
||||
# quit(0)
|
||||
elif line.startsWith("/exit"):
|
||||
await c.node.stop()
|
||||
|
||||
echo "quitting..."
|
||||
quit(QuitSuccess)
|
||||
else:
|
||||
# XXX connected state problematic
|
||||
if c.started:
|
||||
@@ -368,6 +366,7 @@ proc processInput(rfd: AsyncFD, rng: ref BrHmacDrbgContext) {.async.} =
|
||||
node.subscribe(topic, handler)
|
||||
|
||||
await chat.readWriteLoop()
|
||||
|
||||
runForever()
|
||||
#await allFuturesThrowing(libp2pFuts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user