summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/admin.go b/admin.go
index 9aa17f8..a9432bf 100644
--- a/admin.go
+++ b/admin.go
@@ -340,17 +340,19 @@ func (admin AdminConfig) allowedOrigins(addr NetworkAddress) []*url.URL {
// that there is always an admin server (unless it is explicitly
// configured to be disabled).
func replaceLocalAdminServer(cfg *Config) error {
- // always be sure to close down the old admin endpoint
+ // always* be sure to close down the old admin endpoint
// as gracefully as possible, even if the new one is
// disabled -- careful to use reference to the current
// (old) admin endpoint since it will be different
// when the function returns
+ // (* except if the new one fails to start)
oldAdminServer := localAdminServer
+ var err error
defer func() {
// do the shutdown asynchronously so that any
// current API request gets a response; this
// goroutine may last a few seconds
- if oldAdminServer != nil {
+ if oldAdminServer != nil && err == nil {
go func(oldAdminServer *http.Server) {
err := stopAdminServer(oldAdminServer)
if err != nil {