Skip to content

Commit

Permalink
fix: only show error if server broken
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Sep 1, 2024
1 parent 5be8ec4 commit 1312b2a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/webui/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package webui

import (
"errors"
"fmt"
"io"
"log/slog"
"net/http"
Expand All @@ -21,7 +23,12 @@ func HostServer(content []byte, listen string) io.Closer {
}
server.SetKeepAlivesEnabled(false)
go func() {
slog.Error(server.ListenAndServe().Error())
err := server.ListenAndServe()
if errors.Is(err, http.ErrServerClosed) {
slog.Info("webui server closed")
} else {
slog.Error(fmt.Sprintf("webui server error: %v", err))
}
}()
return server
}

0 comments on commit 1312b2a

Please sign in to comment.