summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-05 14:58:07 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-05 14:59:19 -0600
commit3ba9e143a2fbfd6f8c882d5fae51f43099c0ad66 (patch)
tree118e38743bca12cb42b332aa4bd1fb16c6e61e10 /cmd
parent50961ecc77eb7e6a33f823da1d9eea6554a14b43 (diff)
cli: Fix run and start when no config file is available
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/main.go b/cmd/main.go
index e2f1233..3b44a85 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -114,10 +114,17 @@ func loadConfig(configFile, adapterName string) ([]byte, error) {
cfgAdapter = caddyconfig.GetAdapter("caddyfile")
if cfgAdapter != nil {
config, err = ioutil.ReadFile("Caddyfile")
- if err != nil && !os.IsNotExist(err) {
+ if os.IsNotExist(err) {
+ // okay, no default Caddyfile; pretend like this never happened
+ cfgAdapter = nil
+ err = nil
+ } else if err != nil {
+ // default Caddyfile exists, but error reading it
return nil, fmt.Errorf("reading default Caddyfile: %v", err)
+ } else {
+ // success reading default Caddyfile
+ configFile = "Caddyfile"
}
- configFile = "Caddyfile"
}
}