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:
@@ -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,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user