summaryrefslogtreecommitdiff
path: root/cmd/commands.go
diff options
context:
space:
mode:
authorelcore <eldinhadzic@protonmail.com>2020-05-15 23:49:51 +0200
committerGitHub <noreply@github.com>2020-05-15 15:49:51 -0600
commit62c9f2cf3e86f8aaea7a1583f09adb6b8007cfe6 (patch)
tree8407f9f2919a4ef66254fc6b20b361c56fd38901 /cmd/commands.go
parentbde3823b76b457a933e684cd096ca84fc6378997 (diff)
cmd: Add --envfile flag to run command (#3278)
* run: Add the possibility to load an env file * run: change envfile flag var * run: do not ignore err values * Apply suggestions from code review Co-authored-by: Matt Holt <mholt@users.noreply.github.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'cmd/commands.go')
-rw-r--r--cmd/commands.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/commands.go b/cmd/commands.go
index 5a40b1d..99d5245 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -96,7 +96,7 @@ using 'caddy run' instead to keep it in the foreground.`,
RegisterCommand(Command{
Name: "run",
Func: cmdRun,
- Usage: "[--config <path> [--adapter <name>]] [--environ] [--resume] [--watch] [--pidfile <fil>]",
+ Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--environ] [--resume] [--watch] [--pidfile <fil>]",
Short: `Starts the Caddy process and blocks indefinitely`,
Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file,
@@ -116,6 +116,9 @@ As a special case, if the current working directory has a file called
that file will be loaded and used to configure Caddy, even without any command
line flags.
+If --envfile is specified, an environment file with environment variables in
+the KEY=VALUE format will be loaded into the Caddy process.
+
If --environ is specified, the environment as seen by the Caddy process will
be printed before starting. This is the same as the environ command but does
not quit after printing, and can be useful for troubleshooting.
@@ -130,6 +133,7 @@ development environment.`,
fs := flag.NewFlagSet("run", flag.ExitOnError)
fs.String("config", "", "Configuration file")
fs.String("adapter", "", "Name of config adapter to apply")
+ fs.String("envfile", "", "Environment file to load")
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")