mirror of
https://github.com/dragonheim/gagent.git
synced 2025-01-18 09:36:28 -08:00
fix: was using struct member for two different things.
This commit is contained in:
parent
7a9225ce86
commit
db351f3892
5 changed files with 18 additions and 24 deletions
|
@ -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 . .
|
||||
|
|
|
@ -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()
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -18,6 +18,7 @@ type GagentConfig struct {
|
|||
Workers []*WorkerDetails `hcl:"worker,block"`
|
||||
Version string
|
||||
File string
|
||||
Agent string
|
||||
CMode bool
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue