diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-11-04 12:05:20 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-11-04 12:05:20 -0700 |
commit | 35f70c98fa1ea13882ee4f0406cd17f5545d0100 (patch) | |
tree | 71d8a35e62910802431cc4c650da7365ac21041f /cmd | |
parent | fb06c041c4be4eb32f18d54e8e7feff8dd76b0e9 (diff) |
core: Major refactor of admin endpoint and config handling
Fixed several bugs and made other improvements. All config changes are
now mediated by the global config state manager. It used to be that
initial configs given at startup weren't tracked, so you could start
caddy with --config caddy.json and then do a GET /config/ and it would
return null. That is fixed, along with several other general flow/API
enhancements, with more to come.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commandfuncs.go | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index d73644c..e61967b 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -160,23 +160,12 @@ func cmdRun(fl Flags) (int, error) { cleanModVersion := strings.TrimPrefix(goModule.Version, "v") certmagic.UserAgent = "Caddy/" + cleanModVersion - // start the admin endpoint along with any initial config - // a configuration without admin config is considered fine - // but does not enable the admin endpoint at all - err = caddy.StartAdmin(config) - if err == nil { - defer caddy.StopAdmin() - } else if err != caddy.ErrAdminInterfaceNotConfigured { - return caddy.ExitCodeFailedStartup, - fmt.Errorf("starting caddy administration endpoint: %v", err) + // run the initial config + err = caddy.Load(config, true) + if err != nil { + return caddy.ExitCodeFailedStartup, fmt.Errorf("loading initial config: %v", err) } - - // if a config has been supplied, load it as initial config if len(config) > 0 { - err := caddy.Load(bytes.NewReader(config)) - if err != nil { - return caddy.ExitCodeFailedStartup, fmt.Errorf("loading initial config: %v", err) - } caddy.Log().Named("admin").Info("Caddy 2 serving initial configuration") } |