mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:40:13 +08:00
cli: Fix run and start when no config file is available
This commit is contained in:
parent
50961ecc77
commit
3ba9e143a2
11
cmd/main.go
11
cmd/main.go
|
@ -114,12 +114,19 @@ func loadConfig(configFile, adapterName string) ([]byte, error) {
|
||||||
cfgAdapter = caddyconfig.GetAdapter("caddyfile")
|
cfgAdapter = caddyconfig.GetAdapter("caddyfile")
|
||||||
if cfgAdapter != nil {
|
if cfgAdapter != nil {
|
||||||
config, err = ioutil.ReadFile("Caddyfile")
|
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)
|
return nil, fmt.Errorf("reading default Caddyfile: %v", err)
|
||||||
}
|
} else {
|
||||||
|
// success reading default Caddyfile
|
||||||
configFile = "Caddyfile"
|
configFile = "Caddyfile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load config adapter
|
// load config adapter
|
||||||
if adapterName != "" {
|
if adapterName != "" {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user