From a913cb0b5dd78c4b8a7dbf31fef32e91cea40470 Mon Sep 17 00:00:00 2001
From: Mrunal Patel <mpatel@redhat.com>
Date: Thu, 31 Aug 2017 08:45:49 -0700
Subject: [PATCH] server: Use crio socket for info/inspect endpoints

Signed-off-by: Mrunal Patel <mpatel@redhat.com>
---
 cmd/crio/main.go  | 5 +++--
 server/inspect.go | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cmd/crio/main.go b/cmd/crio/main.go
index 959d756f..6f586ecb 100644
--- a/cmd/crio/main.go
+++ b/cmd/crio/main.go
@@ -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)
 			}
 		}()
diff --git a/server/inspect.go b/server/inspect.go
index b132c9e6..7441d5ae 100644
--- a/server/inspect.go
+++ b/server/inspect.go
@@ -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)
 }