diff options
author | Bart <[email protected]> | 2020-07-31 22:54:18 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 16:54:18 -0600 |
commit | af5c148ed1d8e405978b71e7efe15d0a829cab50 (patch) | |
tree | 688bd785a2263e66fb93797abc7a376a3c02726d /admin.go | |
parent | 514eef33fe6ea4e52438e62f73c8f3c0aadd45db (diff) | |
download | caddy-af5c148ed1d8e405978b71e7efe15d0a829cab50.tar.gz caddy-af5c148ed1d8e405978b71e7efe15d0a829cab50.zip |
admin,templates,core: Minor enhancements and error handling (#3607)
* fix 2 possible bugs
* handle unhandled errors
Diffstat (limited to 'admin.go')
-rw-r--r-- | admin.go | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -18,6 +18,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "expvar" "fmt" "io" @@ -235,15 +236,20 @@ func replaceAdmin(cfg *Config) error { MaxHeaderBytes: 1024 * 64, } - go adminServer.Serve(ln) + adminLogger := Log().Named("admin") + go func() { + if err := adminServer.Serve(ln); !errors.Is(err, http.ErrServerClosed) { + adminLogger.Error("admin server shutdown for unknown reason", zap.Error(err)) + } + }() - Log().Named("admin").Info("admin endpoint started", + adminLogger.Info("admin endpoint started", zap.String("address", addr.String()), zap.Bool("enforce_origin", adminConfig.EnforceOrigin), zap.Strings("origins", handler.allowedOrigins)) if !handler.enforceHost { - Log().Named("admin").Warn("admin endpoint on open interface; host checking disabled", + adminLogger.Warn("admin endpoint on open interface; host checking disabled", zap.String("address", addr.String())) } |