add err log

This commit is contained in:
maskpp 2023-09-26 20:16:19 +08:00
parent 82ec555d70
commit a35a6ba19e

View file

@ -19,6 +19,7 @@ package node
import ( import (
"compress/gzip" "compress/gzip"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"net" "net"
@ -171,7 +172,7 @@ func (h *httpServer) start() error {
} }
// Log http endpoint. // Log http endpoint.
h.log.Info("HTTP server started", h.log.Info("HTTP server started",
"endpoint", listener.Addr(), "auth", (h.httpConfig.jwtSecret != nil), "endpoint", listener.Addr(), "auth", h.httpConfig.jwtSecret != nil,
"prefix", h.httpConfig.prefix, "prefix", h.httpConfig.prefix,
"cors", strings.Join(h.httpConfig.CorsAllowedOrigins, ","), "cors", strings.Join(h.httpConfig.CorsAllowedOrigins, ","),
"vhosts", strings.Join(h.httpConfig.Vhosts, ","), "vhosts", strings.Join(h.httpConfig.Vhosts, ","),
@ -279,8 +280,8 @@ func (h *httpServer) doStop() {
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
defer cancel() defer cancel()
err := h.server.Shutdown(ctx) err := h.server.Shutdown(ctx)
if err != nil && err == ctx.Err() { if err != nil && errors.Is(err, ctx.Err()) {
h.log.Warn("HTTP server graceful shutdown timed out") h.log.Warn("HTTP server graceful shutdown timed out", "err", err)
h.server.Close() h.server.Close()
} }