diff options
author | Matthew Holt <[email protected]> | 2019-12-16 13:46:13 -0700 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-12-16 13:46:39 -0700 |
commit | 5ab17a3a371c1f84ef5a649d9310971eb7959271 (patch) | |
tree | ee2550bee5b9e36c29699d33d4c7a1b6d0725e69 /admin.go | |
parent | c3bcd967bd3be85c41ac5f630d496f0dc0d18115 (diff) | |
download | caddy-5ab17a3a371c1f84ef5a649d9310971eb7959271.tar.gz caddy-5ab17a3a371c1f84ef5a649d9310971eb7959271.zip |
admin: /stop endpoint gracefully shuts down; fixes caddy stop command
Diffstat (limited to 'admin.go')
-rw-r--r-- | admin.go | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -561,14 +561,20 @@ func handleConfigID(w http.ResponseWriter, r *http.Request) error { } func handleStop(w http.ResponseWriter, r *http.Request) error { - defer func() { - Log().Named("admin.api").Info("stopping now, bye!! 👋") - os.Exit(0) - }() err := handleUnload(w, r) if err != nil { Log().Named("admin.api").Error("unload error", zap.Error(err)) } + go func() { + err := stopAdminServer(adminServer) + var exitCode int + if err != nil { + exitCode = ExitCodeFailedQuit + Log().Named("admin.api").Error("failed to stop admin server gracefully", zap.Error(err)) + } + Log().Named("admin.api").Info("stopping now, bye!! 👋") + os.Exit(exitCode) + }() return nil } |