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:
2026-09-02 00:15:37 +03:00
parent 536ea9a53e
commit 977da8b109
16 changed files with 247 additions and 193 deletions
+23
View File
@@ -0,0 +1,23 @@
package startup
import (
"fmt"
"strings"
)
const ensureArg = "-ensure"
// ensureTaskTR is the schtasks /TR task action: "<exe> -ensure".
func ensureTaskTR(exe string) string {
return strings.Trim(exe, `"`) + " " + ensureArg
}
// schtasksCreateCmdLine is the full Windows command line for schtasks /Create.
// ponytail: SysProcAttr.CmdLine bypasses Go's /TR quoting bugs.
func schtasksCreateCmdLine(taskName, tr string) string {
return fmt.Sprintf(
`schtasks.exe /Create /TN %s /SC MINUTE /MO 15 /RL LIMITED /F /TR "%s"`,
taskName,
tr,
)
}