summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
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")
}