domain/config.go + app: persist global pause state across restarts (T4.1, T4.2)
Add Config.Paused bool so the scheduler's paused flag survives a restart. SetGlobalPause now writes the flag into store.Config and calls SaveConfig; NewService seeds s.paused from Config.Paused before computing first next-run times, so jobs show "Scheduler paused" immediately at startup when paused. Also add Paused to the yamlConfig shadow struct to keep the direct conversion from domain.Config valid until the YAML import path is dropped in T6.3. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -152,13 +152,17 @@ func (s *Service) SetEnabled(id int, enabled bool) error {
|
||||
func (s *Service) SetGlobalPause(paused bool) error {
|
||||
s.mu.Lock()
|
||||
s.paused = paused
|
||||
s.store.Config.Paused = paused
|
||||
now := time.Now()
|
||||
for index := range s.jobs {
|
||||
job := &s.jobs[index]
|
||||
runtime := s.runtimeForLocked(job)
|
||||
s.refreshNextRunFromLocked(job, runtime, now)
|
||||
}
|
||||
err := s.store.SaveJobs(s.jobs)
|
||||
err := s.store.SaveConfig()
|
||||
if err == nil {
|
||||
err = s.store.SaveJobs(s.jobs)
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
state, detail := "Resumed", "All job execution resumed"
|
||||
|
||||
@@ -82,6 +82,7 @@ func NewService(store *storage.Store, jobs []domain.Job) *Service {
|
||||
schedules: make(map[int]domain.Schedule, len(jobs)),
|
||||
runJob: runner.RunJob,
|
||||
ctx: context.Background(),
|
||||
paused: store.Config.Paused,
|
||||
}
|
||||
// Parse every schedule once, then compute each job's first next-run so the
|
||||
// Service is ready to schedule the moment it exists — mirroring the old
|
||||
|
||||
Reference in New Issue
Block a user