From 00e0df7c87915c4b073626bffeead879166526a9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 6 Jul 2020 17:09:02 +0100 Subject: [PATCH] Yggdrasil demo: Add Stop functions --- build/gobind/monolith.go | 7 +++++++ cmd/dendrite-demo-yggdrasil/yggconn/node.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/build/gobind/monolith.go b/build/gobind/monolith.go index b73e47f86..d415143e9 100644 --- a/build/gobind/monolith.go +++ b/build/gobind/monolith.go @@ -180,3 +180,10 @@ func (m *DendriteMonolith) Start(staticPeer string, enableMulticast bool) { logger.Fatal(httpServer.Serve(m.listener)) }() } + +func (m *DendriteMonolith) Stop() { + if err := m.listener.Close(); err != nil { + logrus.Warn("Error stopping listener:", err) + } + m.YggdrasilNode.Stop() +} diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/node.go b/cmd/dendrite-demo-yggdrasil/yggconn/node.go index 4b08f1f38..c89b0dc1d 100644 --- a/cmd/dendrite-demo-yggdrasil/yggconn/node.go +++ b/cmd/dendrite-demo-yggdrasil/yggconn/node.go @@ -156,6 +156,13 @@ func Setup(instanceName, instancePeer, storageDirectory string, enableMulticast return n, nil } +func (n *Node) Stop() { + if err := n.multicast.Stop(); err != nil { + n.log.Println("Error stopping multicast:", err) + } + n.core.Stop() +} + func (n *Node) DerivedServerName() string { return hex.EncodeToString(n.SigningPublicKey()) }