Only save scheduled stop config if daemonize is successful

pull/9689/head
Priya Wadhwa 2020-11-17 15:14:09 -08:00
parent 5a0ab905ed
commit 4cd74633ca
1 changed files with 11 additions and 3 deletions

View File

@ -41,11 +41,19 @@ func Daemonize(profiles []string, duration time.Duration) error {
continue
}
daemonizeProfiles = append(daemonizeProfiles, p)
}
if err := daemonize(daemonizeProfiles, duration); err != nil {
return errors.Wrap(err, "daemonizing")
}
// save scheduled stop config if daemonize was successful
for _, d := range daemonizeProfiles {
_, cc := mustload.Partial(d)
cc.ScheduledStop = scheduledStop
if err := config.SaveProfile(p, cc); err != nil {
if err := config.SaveProfile(d, cc); err != nil {
return errors.Wrap(err, "saving profile")
}
}
return daemonize(daemonizeProfiles, duration)
return nil
}