fix: (issues/7): Client is now correctly loading the agent.

This commit is contained in:
James Wells 2021-04-03 13:27:18 -07:00
parent 17b097b1b7
commit 8bb01d0266
Signed by: jwells
GPG key ID: 73196D10B8E65666
2 changed files with 9 additions and 3 deletions

View file

@ -31,6 +31,7 @@ var exitCodes = struct {
"AGENT_MISSING_TAGS": 5,
"NO_ROUTERS_DEFINED": 6,
"NO_WORKERS_DEFINED": 7,
"AGENT_NOT_DEFINED": 8,
}}
func main() {
@ -108,7 +109,7 @@ func main() {
err := hclsimple.DecodeFile(configFile, nil, &config)
if err != nil {
log.Printf("Failed to load configuration file: %s.\n", configFile)
log.Printf("%s\n",err)
log.Printf("%s\n", err)
os.Exit(exitCodes.m["CONFIG_FILE_MISSING"])
}
}
@ -125,6 +126,10 @@ func main() {
log.Printf("Arguments are %v\n", arguments)
log.Printf("Configuration is %v\n", config)
log.Printf("Running in client mode\n")
if arguments["--agent"] == nil {
log.Printf("Agent file not specified")
os.Exit(exitCodes.m["AGENT_NOT_DEFINED"])
}
agent, err := ioutil.ReadFile(arguments["--agent"].(string))
if err == nil {
log.Printf("Agent containts %v\n", string(agent))
@ -133,7 +138,7 @@ func main() {
log.Printf("Forked thread has completed\n")
time.Sleep(10 * time.Second)
} else {
log.Printf("Failed to load Agent file: %s.\n", arguments["--agent"].(string))
log.Printf("Failed to load Agent file: %s", arguments["--agent"])
os.Exit(exitCodes.m["AGENT_LOAD_FAILED"])
}