mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-05 20:26:52 +08:00
cmd: Improve stop command by trying API before signaling process
This allows graceful shutdown on all platforms
This commit is contained in:
@ -134,11 +134,18 @@ not quit after printing, and can be useful for troubleshooting.`,
|
||||
Long: `
|
||||
Stops the background Caddy process as gracefully as possible.
|
||||
|
||||
On Windows, this stop is forceful and Caddy will not have an opportunity to
|
||||
clean up any active locks; for a graceful shutdown on Windows, use Ctrl+C
|
||||
or the /stop API endpoint.
|
||||
It will first try to use the admin API's /stop endpoint; the address of
|
||||
this request can be customized using the --address flag if it is not the
|
||||
default.
|
||||
|
||||
Note: this will stop any process named the same as the executable (os.Args[0]).`,
|
||||
If that fails for any reason, it will attempt to signal the first process
|
||||
it can find named the same as this one (os.Args[0]). On Windows, such
|
||||
a stop is forceful because Windows does not have signals.`,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("stop", flag.ExitOnError)
|
||||
fs.String("address", "", "The address to use to reach the admin API endpoint, if not the default")
|
||||
return fs
|
||||
}(),
|
||||
})
|
||||
|
||||
RegisterCommand(Command{
|
||||
|
Reference in New Issue
Block a user