diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-11-15 15:45:18 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-11-15 15:45:18 -0700 |
commit | 6cdb2392d73992099955f9ce859748dea97cf4df (patch) | |
tree | 035fe06136548ac7529ce5ec70a459f2428cf250 /cmd/commands.go | |
parent | 0ca109db4ab0b8869a15d388ef9036d9117ec081 (diff) |
cmd: Improve stop command by trying API before signaling process
This allows graceful shutdown on all platforms
Diffstat (limited to 'cmd/commands.go')
-rw-r--r-- | cmd/commands.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd/commands.go b/cmd/commands.go index 7f43cd0..a861cdf 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -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{ |