()
| 93 | ) |
| 94 | |
| 95 | func init() { |
| 96 | RegisterCommand(Command{ |
| 97 | Name: "start", |
| 98 | Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--watch] [--pidfile <file>]", |
| 99 | Short: "Starts the Caddy process in the background and then returns", |
| 100 | Long: ` |
| 101 | Starts the Caddy process, optionally bootstrapped with an initial config file. |
| 102 | This command unblocks after the server starts running or fails to run. |
| 103 | |
| 104 | If --envfile is specified, an environment file with environment variables |
| 105 | in the KEY=VALUE format will be loaded into the Caddy process. |
| 106 | |
| 107 | On Windows, the spawned child process will remain attached to the terminal, so |
| 108 | closing the window will forcefully stop Caddy; to avoid forgetting this, try |
| 109 | using 'caddy run' instead to keep it in the foreground. |
| 110 | `, |
| 111 | CobraFunc: func(cmd *cobra.Command) { |
| 112 | cmd.Flags().StringP("config", "c", "", "Configuration file") |
| 113 | cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply") |
| 114 | cmd.Flags().StringSliceP("envfile", "", []string{}, "Environment file(s) to load") |
| 115 | cmd.Flags().BoolP("watch", "w", false, "Reload changed config file automatically") |
| 116 | cmd.Flags().StringP("pidfile", "", "", "Path of file to which to write process ID") |
| 117 | cmd.RunE = WrapCommandFuncForCobra(cmdStart) |
| 118 | }, |
| 119 | }) |
| 120 | |
| 121 | RegisterCommand(Command{ |
| 122 | Name: "run", |
| 123 | Usage: "[--config <path> [--adapter <name>]] [--envfile <path>] [--environ] [--resume] [--watch] [--pidfile <file>]", |
| 124 | Short: `Starts the Caddy process and blocks indefinitely`, |
| 125 | Long: ` |
| 126 | Starts the Caddy process, optionally bootstrapped with an initial config file, |
| 127 | and blocks indefinitely until the server is stopped; i.e. runs Caddy in |
| 128 | "daemon" mode (foreground). |
| 129 | |
| 130 | If a config file is specified, it will be applied immediately after the process |
| 131 | is running. If the config file is not in Caddy's native JSON format, you can |
| 132 | specify an adapter with --adapter to adapt the given config file to |
| 133 | Caddy's native format. The config adapter must be a registered module. Any |
| 134 | warnings will be printed to the log, but beware that any adaptation without |
| 135 | errors will immediately be used. If you want to review the results of the |
| 136 | adaptation first, use the 'adapt' subcommand. |
| 137 | |
| 138 | As a special case, if the current working directory has a file called |
| 139 | "Caddyfile" and the caddyfile config adapter is plugged in (default), then |
| 140 | that file will be loaded and used to configure Caddy, even without any command |
| 141 | line flags. |
| 142 | |
| 143 | If --envfile is specified, an environment file with environment variables |
| 144 | in the KEY=VALUE format will be loaded into the Caddy process. |
| 145 | |
| 146 | If --environ is specified, the environment as seen by the Caddy process will |
| 147 | be printed before starting. This is the same as the environ command but does |
| 148 | not quit after printing, and can be useful for troubleshooting. |
| 149 | |
| 150 | The --resume flag will override the --config flag if there is a config auto- |
| 151 | save file. It is not an error if --resume is used and no autosave file exists. |
| 152 |
nothing calls this directly
no test coverage detected