fix: remove unix socket if exists (#220)

This commit is contained in:
Steven Tang 2021-07-10 09:10:55 +00:00 committed by Ferdinand Mütsch
parent 24b8ff6381
commit fecc8b3b5f
1 changed files with 7 additions and 0 deletions

View File

@ -268,6 +268,13 @@ func listen(handler http.Handler) {
// UNIX domain socket
if config.Server.ListenSocket != "" {
// Remove if exists
if _, err := os.Stat(config.Server.ListenSocket); err == nil {
logbuch.Info("--> Removing unix socket %s", config.Server.ListenSocket)
if err := os.Remove(config.Server.ListenSocket); err != nil {
logbuch.Fatal(err.Error())
}
}
sSocket = &http.Server{
Handler: handler,
ReadTimeout: time.Duration(config.Server.TimeoutSec) * time.Second,