Skip to content

Commit

Permalink
RunWithArgs addition
Browse files Browse the repository at this point in the history
  • Loading branch information
iann0036 committed Apr 25, 2021
1 parent f4806bf commit b3a82b4
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions iamlivecore/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,60 @@ func Run() {
fmt.Println("ERROR: unknown mode")
}
}

func RunWithArgs(setIni bool, profile string, failsOnly bool, outputFile string, refreshRate int, sortAlphabetical bool, host, mode, bindAddr, caBundle, caKey, accountID string, background, forceWildcardResource bool) {
setiniFlag = &setIni
profileFlag = &profile
failsonlyFlag = &failsOnly
outputFileFlag = &outputFile
refreshRateFlag = &refreshRate
sortAlphabeticalFlag = &sortAlphabetical
hostFlag = &host
modeFlag = &mode
bindAddrFlag = &bindAddr
caBundleFlag = &caBundle
caKeyFlag = &caKey
accountIDFlag = &accountID
backgroundFlag = &background
forceWildcardResourceFlag = &forceWildcardResource

if *backgroundFlag {
args := os.Args[1:]
for i := 0; i < len(args); i++ {
if args[i] == "-background" || args[i] == "--background" {
args = append(args[:i], args[i+1:]...)
break
}
}
cmd := exec.Command(os.Args[0], args...)
cmd.Start()
fmt.Println(cmd.Process.Pid)
os.Exit(0)
}

if *cpuProfileFlag != "" {
f, err := os.Create(*cpuProfileFlag)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}

if *refreshRateFlag != 0 {
setTerminalRefresh()
}

setINIConfigAndFileFlush()
loadMaps()

if *modeFlag == "csm" {
listenForEvents()
handleLoggedCall()
} else if *modeFlag == "proxy" {
readServiceFiles()
createProxy(*bindAddrFlag)
} else {
fmt.Println("ERROR: unknown mode")
}
}

0 comments on commit b3a82b4

Please sign in to comment.