feat: make environment variables useful.

fix: made config file an environment variable.

fix: reordered and renamed part of the Agent structure.
This commit is contained in:
James Wells 2023-03-30 17:39:04 -07:00
parent 2b0975b30a
commit 8077c66fc9
Signed by: jwells
GPG key ID: 73196D10B8E65666
5 changed files with 50 additions and 27 deletions

View file

@ -105,15 +105,23 @@ LOOP:
/*
* Create listener for client requests
*/
func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) {
func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) error {
defer wg.Done()
clientSock, _ := zmq.NewSocket(zmq.ROUTER)
clientSock, err := zmq.NewSocket(zmq.ROUTER)
if err != nil {
log.Printf("[ERROR] Error creating client socket: %s", err)
return err
}
defer clientSock.Close()
clientListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.ClientPort)
log.Printf("[DEBUG] Binding to: %s", clientListener)
_ = clientSock.Bind(clientListener)
err = clientSock.Bind(clientListener)
if err != nil {
log.Printf("[ERROR] Error binding client socket: %s", err)
return err
}
for {
msg, err := clientSock.RecvMessage(0)
@ -122,6 +130,7 @@ func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) {
}
log.Printf("[DEBUG] Client message received: %s", msg)
}
return nil
}
func unwrap(msg []string) (head string, tail []string) {