feat: restart to apply update, privileged helper, rollback

This commit is contained in:
fsylvain committed 2026-10-01 21:36:40 +02:00
1 parent 70460e4170
commit 54e8fd5fed
63 files changed
+8635 -164

No files matched your search

@@ -0,0 +1,45 @@
package update
import (
domain "RenewCMS/internal/domain/update"
"encoding/json"
"os"
"sync"
)
type JSONRunningInfoStore struct {
path string
mu sync.Mutex
}
var _ domain.RunningInfoStore = &JSONRunningInfoStore{}
func NewJSONRunningInfoStore(path string) *JSONRunningInfoStore {
return &JSONRunningInfoStore{path: path}
}
func (s *JSONRunningInfoStore) Write(info domain.RunningInfo) error {
s.mu.Lock()
defer s.mu.Unlock()
return writeJSONAtomically(s.path, info, readableFilePermissions)
}
func (s *JSONRunningInfoStore) Read() (domain.RunningInfo, bool) {
s.mu.Lock()
defer s.mu.Unlock()
linkInfo, err := os.Lstat(s.path)
if err != nil || !linkInfo.Mode().IsRegular() {
return domain.RunningInfo{}, false
}
content, err := os.ReadFile(s.path)
if err != nil {
return domain.RunningInfo{}, false
}
var info domain.RunningInfo
if err := json.Unmarshal(content, &info); err != nil || info.Version == "" || info.Pid == 0 {
return domain.RunningInfo{}, false
}
return info, true
}