Merge pull request #826 from mrunalp/info_sock

server: Use crio socket for info/inspect endpoints
This commit is contained in:
Antonio Murdaca 2017-09-01 11:09:54 +02:00 committed by GitHub
commit f3bbd44734
2 changed files with 6 additions and 5 deletions

View file

@ -413,8 +413,9 @@ func main() {
}()
go func() {
err := service.StartInfoEndpoints()
if err != nil {
err := service.StartInfoEndpoints(lis)
// graceful shutdown doesn't quite work with unix domain sockets
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
logrus.Fatalf("Failed to start container inspect endpoint: %v", err)
}
}()

View file

@ -3,6 +3,7 @@ package server
import (
"encoding/json"
"fmt"
"net"
"net/http"
"path/filepath"
@ -28,7 +29,7 @@ type CrioInfo struct {
// StartInfoEndpoints starts a http server that
// serves container information requests and crio daemon information
func (s *Server) StartInfoEndpoints() error {
func (s *Server) StartInfoEndpoints(l net.Listener) error {
mux := bone.New()
mux.Get("/info", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@ -76,6 +77,5 @@ func (s *Server) StartInfoEndpoints() error {
w.Write(js)
}))
// TODO: Make this configurable
return http.ListenAndServe("localhost:7373", mux)
return http.Serve(l, mux)
}