From 14493e2a4a08af331ab05b7c43e0bd263d9f0406 Mon Sep 17 00:00:00 2001 From: postmannen Date: Wed, 5 Jan 2022 19:53:26 +0100 Subject: [PATCH] added removal of stew.sock on exit --- server.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 6ae701f..3cd2d1a 100644 --- a/server.go +++ b/server.go @@ -290,7 +290,7 @@ func (s *server) Stop() { s.cancel() log.Printf("info: stopped the main context\n") - // Delete the socket file when the program exits. + // Delete the steward socket file when the program exits. socketFilepath := filepath.Join(s.configuration.SocketFolder, "steward.sock") if _, err := os.Stat(socketFilepath); !os.IsNotExist(err) { @@ -301,6 +301,17 @@ func (s *server) Stop() { } } + // Delete the steward socket file when the program exits. + stewSocketFilepath := filepath.Join(s.configuration.SocketFolder, "stew.sock") + + if _, err := os.Stat(stewSocketFilepath); !os.IsNotExist(err) { + err = os.Remove(stewSocketFilepath) + if err != nil { + er := fmt.Errorf("error: could not delete sock file: %v", err) + log.Printf("%v\n", er) + } + } + } // sendErrorMessage will put the error message directly on the channel that is