fix(startup): make watchdog task keep agent alive
- Use Task Scheduler XML instead of /TR - Run -ensure agent in-process, not child - Add console close and panic protection - Guard nil event channels after stop - Add non-Windows stubs for startup/mutex
This commit is contained in:
+11
-2
@@ -1,9 +1,18 @@
|
||||
package instance
|
||||
|
||||
// EnsureRunning starts a detached agent if none is holding the mutex.
|
||||
import (
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/config"
|
||||
)
|
||||
|
||||
// EnsureRunning starts this host's agent if none is holding the mutex.
|
||||
// Callers that can stay resident should run the agent in-process instead.
|
||||
func EnsureRunning() error {
|
||||
if AlreadyRunning() {
|
||||
return nil
|
||||
}
|
||||
return Detach()
|
||||
exe, err := config.InstalledExe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return Launch(exe, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user