Repository: caddyserver/caddy
File: cmd/commands.go (Go)

Code before:
}

var commands = make(map[string]Command)

func init() {
	RegisterCommand(Command{
		Name:  "start",
		Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--watch] [--pidfile <file>]",
		Short: "Starts the Caddy process in the background and then returns",
		Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file.
This command unblocks after the server starts running or fails to run.

If --envfile is specified, an environment file with environment variables in
the KEY=VALUE format will be loaded into the Caddy process.

On Windows, the spawned child process will remain attached to the terminal, so
closing the window will forcefully stop Caddy; to avoid forgetting this, try
using 'caddy run' instead to keep it in the foreground.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("envfile", "f", "", "Environment file to load")
			cmd.Flags().BoolP("watch", "w", false, "Reload changed config file automatically")
			cmd.Flags().StringP("pidfile", "p", "", "Path of file to which to write process ID")
			cmd.RunE = WrapCommandFuncForCobra(cmdStart)
		},
	})

	RegisterCommand(Command{
		Name:  "run",
		Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--environ] [--resume] [--watch] [--pidfile <file>]",
		Short: `Starts the Caddy process and blocks indefinitely`,
		Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file,
and blocks indefinitely until the server is stopped; i.e. runs Caddy in
"daemon" mode (foreground).

If a config file is specified, it will be applied immediately after the process
is running. If the config file is not in Caddy's native JSON format, you can
specify an adapter with --adapter to adapt the given config file to
Caddy's native format. The config adapter must be a registered module. Any
warnings will be printed to the log, but beware that any adaptation without
errors will immediately be used. If you want to review the results of the
adaptation first, use the 'adapt' subcommand.

As a special case, if the current working directory has a file called
"Caddyfile" and the caddyfile config adapter is plugged in (default), then
that file will be loaded and used to configure Caddy, even without any command
line flags.

Review comment (suggestion):
```suggestion
			cmd.Flags().StringP("pidfile", "", "", "Path of file to which to write process ID")
```

Code after:
}

var commands = make(map[string]Command)

func init() {
	RegisterCommand(Command{
		Name:  "start",
		Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--watch] [--pidfile <file>]",
		Short: "Starts the Caddy process in the background and then returns",
		Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file.
This command unblocks after the server starts running or fails to run.

If --envfile is specified, an environment file with environment variables in
the KEY=VALUE format will be loaded into the Caddy process.

On Windows, the spawned child process will remain attached to the terminal, so
closing the window will forcefully stop Caddy; to avoid forgetting this, try
using 'caddy run' instead to keep it in the foreground.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("envfile", "", "", "Environment file to load")
			cmd.Flags().BoolP("watch", "w", false, "Reload changed config file automatically")
			cmd.Flags().StringP("pidfile", "", "", "Path of file to which to write process ID")
			cmd.RunE = WrapCommandFuncForCobra(cmdStart)
		},
	})

	RegisterCommand(Command{
		Name:  "run",
		Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--environ] [--resume] [--watch] [--pidfile <file>]",
		Short: `Starts the Caddy process and blocks indefinitely`,
		Long: `
Starts the Caddy process, optionally bootstrapped with an initial config file,
and blocks indefinitely until the server is stopped; i.e. runs Caddy in
"daemon" mode (foreground).

If a config file is specified, it will be applied immediately after the process
is running. If the config file is not in Caddy's native JSON format, you can
specify an adapter with --adapter to adapt the given config file to
Caddy's native format. The config adapter must be a registered module. Any
warnings will be printed to the log, but beware that any adaptation without
errors will immediately be used. If you want to review the results of the
adaptation first, use the 'adapt' subcommand.

As a special case, if the current working directory has a file called
"Caddyfile" and the caddyfile config adapter is plugged in (default), then
that file will be loaded and used to configure Caddy, even without any command
line flags.