From 2378a1983aff96f5da6731448f3eecf77a3433b9 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 20 Sep 2016 12:30:52 +0200 Subject: [PATCH 1/2] .gitignore: use absolute paths Signed-off-by: Antonio Murdaca --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8d9d1c42..e0d2b2a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -ocid -ocic +/ocid +/ocic conmon/conmon conmon/conmon.o From 910f343f79becd27dc8256049f565e4e23916dc7 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 20 Sep 2016 12:31:10 +0200 Subject: [PATCH 2/2] cmd/server: add socket flag Signed-off-by: Antonio Murdaca --- cmd/server/main.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index ddf3e171..9f9731ed 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -12,10 +12,6 @@ import ( "google.golang.org/grpc" ) -const ( - unixDomainSocket = "/var/run/ocid.sock" -) - func main() { app := cli.NewApp() app.Name = "ocic" @@ -27,16 +23,21 @@ func main() { Value: "/var/lib/ocid/sandboxes", Usage: "ocid pod sandbox dir", }, - cli.StringFlag{ - Name: "runtime", - Value: "/usr/bin/runc", - Usage: "OCI runtime path", - }, cli.StringFlag{ Name: "containerdir", Value: "/var/lib/ocid/containers", Usage: "ocid container dir", }, + cli.StringFlag{ + Name: "socket", + Value: "/var/run/ocid.sock", + Usage: "path to ocid socket", + }, + cli.StringFlag{ + Name: "runtime", + Value: "/usr/bin/runc", + Usage: "OCI runtime path", + }, cli.BoolFlag{ Name: "debug", Usage: "enable debug output for logging", @@ -76,13 +77,14 @@ func main() { } app.Action = func(c *cli.Context) error { + socketPath := c.String("socket") // Remove the socket if it already exists - if _, err := os.Stat(unixDomainSocket); err == nil { - if err := os.Remove(unixDomainSocket); err != nil { + if _, err := os.Stat(socketPath); err == nil { + if err := os.Remove(socketPath); err != nil { logrus.Fatal(err) } } - lis, err := net.Listen("unix", unixDomainSocket) + lis, err := net.Listen("unix", socketPath) if err != nil { logrus.Fatalf("failed to listen: %v", err) }