1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

added removal of stew.sock on exit

This commit is contained in:
postmannen 2022-01-05 19:53:26 +01:00
parent 2028cf9040
commit 14493e2a4a

View file

@ -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