MCPcopy
hub / github.com/caddyserver/caddy / init

Function init

cmd/commands.go:95–562  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93)
94
95func 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: `
101Starts the Caddy process, optionally bootstrapped with an initial config file.
102This command unblocks after the server starts running or fails to run.
103
104If --envfile is specified, an environment file with environment variables
105in the KEY=VALUE format will be loaded into the Caddy process.
106
107On Windows, the spawned child process will remain attached to the terminal, so
108closing the window will forcefully stop Caddy; to avoid forgetting this, try
109using '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: `
126Starts the Caddy process, optionally bootstrapped with an initial config file,
127and blocks indefinitely until the server is stopped; i.e. runs Caddy in
128"daemon" mode (foreground).
129
130If a config file is specified, it will be applied immediately after the process
131is running. If the config file is not in Caddy's native JSON format, you can
132specify an adapter with --adapter to adapt the given config file to
133Caddy's native format. The config adapter must be a registered module. Any
134warnings will be printed to the log, but beware that any adaptation without
135errors will immediately be used. If you want to review the results of the
136adaptation first, use the 'adapt' subcommand.
137
138As a special case, if the current working directory has a file called
139"Caddyfile" and the caddyfile config adapter is plugged in (default), then
140that file will be loaded and used to configure Caddy, even without any command
141line flags.
142
143If --envfile is specified, an environment file with environment variables
144in the KEY=VALUE format will be loaded into the Caddy process.
145
146If --environ is specified, the environment as seen by the Caddy process will
147be printed before starting. This is the same as the environ command but does
148not quit after printing, and can be useful for troubleshooting.
149
150The --resume flag will override the --config flag if there is a config auto-
151save file. It is not an error if --resume is used and no autosave file exists.
152

Callers

nothing calls this directly

Calls 6

RegisterCommandFunction · 0.85
WrapCommandFuncForCobraFunction · 0.85
caddyCmdToCobraFunction · 0.85
UseMethod · 0.80
StringMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected