提交 cc830ff2 作者: Tor Arne Vestbø 提交者: Tor Arne Vestbø

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.
上级 61efc4de
......@@ -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)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论