summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:05:20 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:05:20 -0700
commit35f70c98fa1ea13882ee4f0406cd17f5545d0100 (patch)
tree71d8a35e62910802431cc4c650da7365ac21041f /cmd
parentfb06c041c4be4eb32f18d54e8e7feff8dd76b0e9 (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.go19
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")
}