summaryrefslogtreecommitdiffhomepage
path: root/caddy.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-12-31 22:51:55 -0700
committerMatthew Holt <[email protected]>2019-12-31 22:51:55 -0700
commit3d9f8eac08e172d99eafb396f161263fd444c073 (patch)
tree747de0d1ee29c819a61ec4d2a2dfc723f6732a7b /caddy.go
parent06ea0a52950ef6d1dd327c10e247ada1b71a5c5d (diff)
downloadcaddy-3d9f8eac08e172d99eafb396f161263fd444c073.tar.gz
caddy-3d9f8eac08e172d99eafb396f161263fd444c073.zip
Couple of minor fixes, update readmev2.0.0-beta12
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/caddy.go b/caddy.go
index ab7c01483..dc4ea9e75 100644
--- a/caddy.go
+++ b/caddy.go
@@ -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))
+ }
}
}