feat(watchdog): separate watchdog from startup
- Add /api/v1/watchdog to enable/disable - Scheduled task now runs every 15 minutes - Use schtasks command line instead of XML - Dashboard shows watchdog enabled state - Preserve watchdog state during install
This commit is contained in:
@@ -44,6 +44,7 @@ func Ensure() error {
|
||||
}
|
||||
|
||||
hadStartup := startup.Enabled()
|
||||
hadWatchdog := startup.WatchdogEnabled()
|
||||
takeover(target)
|
||||
if err := replaceExe(current, target); err != nil {
|
||||
return fmt.Errorf("copy to %s: %w", target, err)
|
||||
@@ -53,6 +54,11 @@ func Ensure() error {
|
||||
helpers.Log.Printf("takeover: restore startup: %v", err)
|
||||
}
|
||||
}
|
||||
if hadWatchdog {
|
||||
if err := startup.EnableWatchdog(); err != nil {
|
||||
helpers.Log.Printf("takeover: restore watchdog: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return relaunchInstalled(target)
|
||||
}
|
||||
@@ -62,6 +68,9 @@ func takeover(installed string) {
|
||||
if err := startup.Disable(); err != nil {
|
||||
helpers.Log.Printf("takeover: disable old startup: %v", err)
|
||||
}
|
||||
if err := startup.DisableWatchdog(); err != nil {
|
||||
helpers.Log.Printf("takeover: disable old watchdog: %v", err)
|
||||
}
|
||||
if err := instance.KillOtherAgents(); err != nil {
|
||||
helpers.Log.Printf("takeover: kill: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user