Config: persist settings immediately on site update (#31754)
This commit is contained in:
parent
83a2b7de23
commit
43627f6649
2 changed files with 8 additions and 1 deletions
|
|
@ -669,7 +669,7 @@ func configureDatabase(conf globalconfig.DB) error {
|
|||
// persist unsaved settings on shutdown
|
||||
shutdown.Register(persistSettings)
|
||||
|
||||
// persist unsaved settings every 30 minutes
|
||||
// persist unsaved settings every minute
|
||||
go func() {
|
||||
for range time.Tick(time.Minute) {
|
||||
persistSettings()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/evcc-io/evcc/core/site"
|
||||
"github.com/evcc-io/evcc/server/db/settings"
|
||||
"github.com/evcc-io/evcc/util/config"
|
||||
)
|
||||
|
||||
|
|
@ -118,6 +119,12 @@ func updateSiteHandler(site site.API) http.HandlerFunc {
|
|||
setConfigDirty()
|
||||
}
|
||||
|
||||
// persist immediately to keep meter refs consistent with device config on unclean shutdown
|
||||
if err := settings.Persist(); err != nil {
|
||||
jsonError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
status := map[bool]int{false: http.StatusOK, true: http.StatusAccepted}
|
||||
w.WriteHeader(status[ConfigDirty()])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue