mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
Add /stop endpoint to admin (#2671)
* Add stop command to admin. Exit after stop. * Return error on incorrect http Method and provide better logging. * reuse stopAndCleanup function for all graceful stops
This commit is contained in:
parent
b855e66170
commit
d98f2faef9
2 changed files with 26 additions and 8 deletions
|
@ -18,8 +18,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"github.com/mholt/certmagic"
|
||||
)
|
||||
|
||||
// TrapSignals create signal/interrupt handlers as best it can for the
|
||||
|
@ -57,16 +55,12 @@ func trapSignalsCrossPlatform() {
|
|||
func gracefulStop(sigName string) {
|
||||
exitCode := ExitCodeSuccess
|
||||
|
||||
// first stop all the apps
|
||||
err := Stop()
|
||||
err := stopAndCleanup()
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %s stop: %v", sigName, err)
|
||||
exitCode = ExitCodeFailedQuit
|
||||
}
|
||||
|
||||
// always, always, always try to clean up locks
|
||||
certmagic.CleanUpOwnLocks()
|
||||
|
||||
log.Printf("[INFO] %s: Shutdown done", sigName)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue