etcdmain: discard the http server logging

release-2.0
Xiang Li 2014-12-11 15:11:20 -08:00
parent 2e9f6f70d6
commit 3a83ab1b71
2 changed files with 23 additions and 2 deletions

View File

@ -313,13 +313,13 @@ func startEtcd() (<-chan struct{}, error) {
// Start the peer server in a goroutine
for _, l := range plns {
go func(l net.Listener) {
log.Fatal(http.Serve(l, ph))
log.Fatal(serveHTTP(l, ph))
}(l)
}
// Start a client server goroutine for each listen address
for _, l := range clns {
go func(l net.Listener) {
log.Fatal(http.Serve(l, ch))
log.Fatal(serveHTTP(l, ch))
}(l)
}
return s.StopNotify(), nil

21
etcdmain/http.go Normal file
View File

@ -0,0 +1,21 @@
package etcdmain
import (
"io/ioutil"
"log"
"net"
"net/http"
)
// serveHTTP accepts incoming HTTP connections on the listener l,
// creating a new service goroutine for each. The service goroutines
// read requests and then call handler to reply to them.
func serveHTTP(l net.Listener, handler http.Handler) error {
logger := log.New(ioutil.Discard, "etcdhttp", 0)
// TODO: add debug flag; enable logging when debug flag is set
srv := &http.Server{
Handler: handler,
ErrorLog: logger, // do not log user error
}
return srv.Serve(l)
}