summaryrefslogtreecommitdiff
path: root/cmd/commands.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-03-22 22:58:24 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-03-22 22:58:33 -0600
commit6e2fabb2a46812dee42842c13439e1a0238aa40b (patch)
treeb4991c00ae7e8efc470ab36213d2e5ddd2f8559a /cmd/commands.go
parent8cc60e6896b7c030891a3578ae2405a14b2fed49 (diff)
cmd: Add --watch flag to start & run commands (closes #1806)
Because, just for fun.
Diffstat (limited to 'cmd/commands.go')
-rw-r--r--cmd/commands.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd/commands.go b/cmd/commands.go
index d4edc66..43aba01 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -74,7 +74,7 @@ func init() {
RegisterCommand(Command{
Name: "start",
Func: cmdStart,
- Usage: "[--config <path> [[--adapter <name>]]",
+ Usage: "[--config <path> [--adapter <name>]] [--watch]",
Short: "Starts the Caddy process in the background and then returns",
Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file.
@@ -87,6 +87,7 @@ using 'caddy run' instead to keep it in the foreground.`,
fs := flag.NewFlagSet("start", flag.ExitOnError)
fs.String("config", "", "Configuration file")
fs.String("adapter", "", "Name of config adapter to apply")
+ fs.Bool("watch", false, "Reload changed config file automatically")
return fs
}(),
})
@@ -94,7 +95,7 @@ using 'caddy run' instead to keep it in the foreground.`,
RegisterCommand(Command{
Name: "run",
Func: cmdRun,
- Usage: "[--config <path> [--adapter <name>]] [--environ]",
+ Usage: "[--config <path> [--adapter <name>]] [--environ] [--watch]",
Short: `Starts the Caddy process and blocks indefinitely`,
Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file,
@@ -119,13 +120,18 @@ be printed before starting. This is the same as the environ command but does
not quit after printing, and can be useful for troubleshooting.
The --resume flag will override the --config flag if there is a config auto-
-save file. It is not an error if --resume is used and no autosave file exists.`,
+save file. It is not an error if --resume is used and no autosave file exists.
+
+If --watch is specified, the config file will be loaded automatically after
+changes. ⚠️ This is dangerous in production! Only use this option in a local
+development environment.`,
Flags: func() *flag.FlagSet {
fs := flag.NewFlagSet("run", flag.ExitOnError)
fs.String("config", "", "Configuration file")
fs.String("adapter", "", "Name of config adapter to apply")
- fs.Bool("resume", false, "Use saved config, if any (and prefer over --config file)")
fs.Bool("environ", false, "Print environment")
+ fs.Bool("resume", false, "Use saved config, if any (and prefer over --config file)")
+ fs.Bool("watch", false, "Watch config file for changes and reload it automatically")
fs.String("pingback", "", "Echo confirmation bytes to this address on success")
return fs
}(),