summaryrefslogtreecommitdiff
path: root/cmd/commands.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-15 15:45:18 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-15 15:45:18 -0700
commit6cdb2392d73992099955f9ce859748dea97cf4df (patch)
tree035fe06136548ac7529ce5ec70a459f2428cf250 /cmd/commands.go
parent0ca109db4ab0b8869a15d388ef9036d9117ec081 (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.go15
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{