mirror of
https://github.com/dragonheim/gagent.git
synced 2025-04-26 03:28:59 -07:00
Extending prometheus support.
This commit is contained in:
parent
16d40fd93a
commit
8a7842e6bc
4 changed files with 62 additions and 37 deletions
|
@ -9,26 +9,38 @@ import (
|
|||
gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs"
|
||||
|
||||
// picol "git.dragonheim.net/dragonheim/gagent/src/picol"
|
||||
|
||||
promhttp "github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
zmq "github.com/pebbe/zmq4"
|
||||
)
|
||||
|
||||
// Main is the initiation function for a Worker
|
||||
/*
|
||||
The "worker" processes the agent code. The worker nodes do not know
|
||||
anything about the network structure. Instead they know only to which
|
||||
router(s) they are connected. The worker will execute the agent code and
|
||||
pass the agent and it's results to a router.
|
||||
*/
|
||||
func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int) {
|
||||
defer wg.Done()
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
log.Printf("[INFO] Starting worker\n")
|
||||
|
||||
// Generate connect string for this router.
|
||||
var rport = int64(config.WorkerPort)
|
||||
var rport = config.WorkerPort
|
||||
if config.Routers[rid].WorkerPort != 0 {
|
||||
rport = config.Routers[rid].WorkerPort
|
||||
}
|
||||
connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[rid].RouterAddr, rport)
|
||||
// workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort)
|
||||
clientListener := fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort)
|
||||
|
||||
subscriber, _ := zmq.NewSocket(zmq.REP)
|
||||
defer subscriber.Close()
|
||||
|
||||
go func() {
|
||||
http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil)
|
||||
http.ListenAndServe(clientListener, nil)
|
||||
}()
|
||||
|
||||
log.Printf("[DEBUG] Attempting to connect to %s\n", connectString)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue