diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index a7a80cd..f652599 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,5 @@ -FROM nikatjef/golang:1.20 as builder -ARG SEMVER=${SEMVER:-0.0.8} +FROM dragonheim/golang:1.20 as builder +ARG SEMVER=${SEMVER:-0.0.9} WORKDIR /gagent COPY . . diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 2101ab8..52cfc5a 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -4,7 +4,6 @@ import ( log "log" http "net/http" os "os" - strconv "strconv" sync "sync" autorestart "github.com/slayer/autorestart" @@ -56,7 +55,7 @@ var environment struct { * This is the application version number. It can be overridden at build time * using the -ldflags "-X main.semVER=0.0.1" option. */ -var semVER = "0.0.8" +var semVER = "0.0.9" /* * This is the application configuration. It is populated from the configuration @@ -131,8 +130,6 @@ func main() { * reads the environment variables. It also sets up the logging. */ func init() { - autorestart.StartWatcher() - cfg := environment if err := env.Parse(&cfg); err != nil { log.Printf("%+v\n", err) @@ -261,7 +258,7 @@ func init() { log.Printf("[ERROR] Agent file not specified") os.Exit(8) } else { - config.File = opts["--agent"].(string) + config.Agent = opts["--agent"].(string) } if opts["pull"] == true { @@ -287,10 +284,13 @@ func init() { /* * Start Prometheus metrics exporter */ - if config.MonitorPort != 0 { - go func() { - log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) - }() - } + // if config.MonitorPort != 0 { + // go func() { + // log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) + // log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) + // }() + // } + autorestart.WatchFilename = config.File + autorestart.StartWatcher() + } diff --git a/internal/client/client.go b/internal/client/client.go index 413eb93..3f894ca 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -8,6 +8,7 @@ import ( log "log" os "os" regexp "regexp" + strconv "strconv" strings "strings" sync "sync" time "time" @@ -33,9 +34,9 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { var err error if config.CMode { - agent.ScriptCode, err = ioutil.ReadFile(config.File) + agent.ScriptCode, err = ioutil.ReadFile(config.Agent) if err != nil { - log.Printf("[ERROR] No such file or directory: %s", config.File) + log.Printf("[ERROR] No such file or directory: %s", config.Agent) os.Exit(4) } log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) @@ -56,7 +57,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { if config.Routers[key].ClientPort != 0 { rport = config.Routers[key].ClientPort } - connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) + connectString := "tcp://" + config.Routers[key].RouterAddr + ":" + strconv.Itoa(rport) wg.Add(1) go sendAgent(wg, config.UUID, connectString, agent) diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 5db81d9..851c93c 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -18,6 +18,7 @@ type GagentConfig struct { Workers []*WorkerDetails `hcl:"worker,block"` Version string File string + Agent string CMode bool } diff --git a/internal/router/router.go b/internal/router/router.go index 906f831..b2eca6c 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -10,17 +10,10 @@ import ( gcdb "github.com/dragonheim/gagent/internal/chaindb" gstructs "github.com/dragonheim/gagent/internal/gstructs" - prometheus "github.com/prometheus/client_golang/prometheus" - promauto "github.com/prometheus/client_golang/prometheus/promauto" - zmq "github.com/pebbe/zmq4" ) var ( - opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ - Name: "client_requests_received", - }) - db gcdb.GagentDb ) @@ -144,7 +137,6 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { - opsProcessed.Inc() /* * fmt.Fprintf(w, "%v\n", r) */