Commit 638065c8 authored by Janos Guljas's avatar Janos Guljas

close libp2p server on application stop

parent c8cbe79e
......@@ -138,11 +138,14 @@ func (c *command) initStartCmd() (err error) {
if err := debugAPIServer.Shutdown(ctx); err != nil {
log.Println("debug api server shutdown:", err)
}
if err := p2ps.Close(); err != nil {
log.Println("p2p server shutdown:", err)
}
}()
// If shutdown function is blocking too long,
// allow process termination by receiving another signal.
// Blocking part
select {
case sig := <-interruptChannel:
log.Printf("received signal: %v\n", sig)
......
......@@ -207,3 +207,7 @@ func (s *Service) NewStream(ctx context.Context, peerID, protocolName, streamNam
}
return st, nil
}
func (s *Service) Close() error {
return s.host.Close()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment