@marcel91200 / caddy Mirror · read-only / commits / 3ba9e143
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

cli: Fix run and start when no config file is available

Matthew Holt committed Sep 5, 2019 at 14:58 UTC 3ba9e143a2fbfd6f8c882d5fae51f43099c0ad66
1 file changed +9 -2
cmd/main.go
+9 -2
@@ -114,10 +114,17 @@ func loadConfig(configFile, adapterName string) ([]byte, error) {
114 cfgAdapter = caddyconfig.GetAdapter("caddyfile")
115 if cfgAdapter != nil {
116 config, err = ioutil.ReadFile("Caddyfile")
117 - if err != nil && !os.IsNotExist(err) {
117 + if os.IsNotExist(err) {
118 + // okay, no default Caddyfile; pretend like this never happened
119 + cfgAdapter = nil
120 + err = nil
121 + } else if err != nil {
122 + // default Caddyfile exists, but error reading it
123 return nil, fmt.Errorf("reading default Caddyfile: %v", err)
124 + } else {
125 + // success reading default Caddyfile
126 + configFile = "Caddyfile"
127 }
120 - configFile = "Caddyfile"
128 }
129 }
130