mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 06:17:56 +08:00
corehttp: log when server takes a long time to shut down
The server may stay alive for quite a while due to waiting on open connections to close before shutting down. We should find ways to terminate these connections in a more controlled manner, but in the meantime it's helpful to be able to see why a shutdown of the ipfs daemon is taking so long.
This commit is contained in:
parent
61efc4de1d
commit
cc830ff2ee
@ -2,6 +2,7 @@ package corehttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
manners "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners"
|
||||
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||
@ -76,7 +77,17 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler
|
||||
case <-node.Closing():
|
||||
log.Infof("server at %s terminating...", addr)
|
||||
server.Shutdown <- true
|
||||
<-serverExited // now, DO wait until server exit
|
||||
|
||||
outer:
|
||||
for {
|
||||
// wait until server exits
|
||||
select {
|
||||
case <-serverExited:
|
||||
break outer
|
||||
case <-time.After(5 * time.Second):
|
||||
log.Infof("waiting for server at %s to terminate...", addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof("server at %s terminated", addr)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user