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) { ...@@ -138,11 +138,14 @@ func (c *command) initStartCmd() (err error) {
if err := debugAPIServer.Shutdown(ctx); err != nil { if err := debugAPIServer.Shutdown(ctx); err != nil {
log.Println("debug api server shutdown:", err) 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, // If shutdown function is blocking too long,
// allow process termination by receiving another signal. // allow process termination by receiving another signal.
// Blocking part
select { select {
case sig := <-interruptChannel: case sig := <-interruptChannel:
log.Printf("received signal: %v\n", sig) log.Printf("received signal: %v\n", sig)
......
...@@ -207,3 +207,7 @@ func (s *Service) NewStream(ctx context.Context, peerID, protocolName, streamNam ...@@ -207,3 +207,7 @@ func (s *Service) NewStream(ctx context.Context, peerID, protocolName, streamNam
} }
return st, nil 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