diff options
author | Matthew Holt <[email protected]> | 2019-12-31 22:51:55 -0700 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-12-31 22:51:55 -0700 |
commit | 3d9f8eac08e172d99eafb396f161263fd444c073 (patch) | |
tree | 747de0d1ee29c819a61ec4d2a2dfc723f6732a7b /caddy.go | |
parent | 06ea0a52950ef6d1dd327c10e247ada1b71a5c5d (diff) | |
download | caddy-3d9f8eac08e172d99eafb396f161263fd444c073.tar.gz caddy-3d9f8eac08e172d99eafb396f161263fd444c073.zip |
Couple of minor fixes, update readmev2.0.0-beta12
Diffstat (limited to 'caddy.go')
-rw-r--r-- | caddy.go | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -23,7 +23,9 @@ import ( "io/ioutil" "log" "net/http" + "os" "path" + "path/filepath" "runtime/debug" "strconv" "strings" @@ -262,13 +264,21 @@ func unsyncedDecodeAndRun(cfgJSON []byte) error { newCfg.Admin.Config == nil || newCfg.Admin.Config.Persist == nil || *newCfg.Admin.Config.Persist) { - err := ioutil.WriteFile(ConfigAutosavePath, cfgJSON, 0600) - if err == nil { - Log().Info("autosaved config", zap.String("file", ConfigAutosavePath)) - } else { - Log().Error("unable to autosave config", - zap.String("file", ConfigAutosavePath), + dir := filepath.Dir(ConfigAutosavePath) + err := os.MkdirAll(dir, 0700) + if err != nil { + Log().Error("unable to create folder for config autosave", + zap.String("dir", dir), zap.Error(err)) + } else { + err := ioutil.WriteFile(ConfigAutosavePath, cfgJSON, 0600) + if err == nil { + Log().Info("autosaved config", zap.String("file", ConfigAutosavePath)) + } else { + Log().Error("unable to autosave config", + zap.String("file", ConfigAutosavePath), + zap.Error(err)) + } } } |