1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

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

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,