Merge remote-tracking branch 'upstream/develop' into BigRefactor
This commit is contained in:
commit
be0ea6b544
4 changed files with 68 additions and 36 deletions
|
|
@ -118,7 +118,13 @@ func New(logger *logrus.Logger, version string) *Agent {
|
|||
natsProxyPort = "443"
|
||||
}
|
||||
|
||||
natsServer := fmt.Sprintf("wss://%s:%s", ac.APIURL, natsProxyPort)
|
||||
// check if using nats standard tcp, otherwise use nats websockets by default
|
||||
var natsServer string
|
||||
if ac.NatsStandardPort != "" {
|
||||
natsServer = fmt.Sprintf("tls://%s:%s", ac.APIURL, ac.NatsStandardPort)
|
||||
} else {
|
||||
natsServer = fmt.Sprintf("wss://%s:%s", ac.APIURL, natsProxyPort)
|
||||
}
|
||||
|
||||
return &Agent{
|
||||
Hostname: info.Hostname,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -156,6 +157,7 @@ func NewAgentConfig() *rmm.AgentConfig {
|
|||
CustomMeshDir: viper.GetString("meshdir"),
|
||||
NatsProxyPath: viper.GetString("natsproxypath"),
|
||||
NatsProxyPort: viper.GetString("natsproxyport"),
|
||||
NatsStandardPort: viper.GetString("natsstandardport"),
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
@ -249,9 +251,30 @@ func (a *Agent) AgentUpdate(url, inno, version string) {
|
|||
os.Chmod(f.Name(), 0755)
|
||||
err = os.Rename(f.Name(), self)
|
||||
if err != nil {
|
||||
a.Logger.Errorln("AgentUpdate() os.Rename():", err)
|
||||
a.Logger.Debugln("Detected /tmp on different filesystem")
|
||||
// rename does not work when src and dest are on different filesystems
|
||||
// so we need to manually copy it to the same fs then rename it
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
a.Logger.Errorln("AgentUpdate() os.Getwd():", err)
|
||||
return
|
||||
}
|
||||
// create a tmpfile in same fs as agent
|
||||
tmpfile := filepath.Join(cwd, GenerateAgentID())
|
||||
defer os.Remove(tmpfile)
|
||||
a.Logger.Debugln("Copying tmpfile from", f.Name(), "to", tmpfile)
|
||||
cperr := copyFile(f.Name(), tmpfile)
|
||||
if cperr != nil {
|
||||
a.Logger.Errorln("AgentUpdate() copyFile:", cperr)
|
||||
return
|
||||
}
|
||||
os.Chmod(tmpfile, 0755)
|
||||
rerr := os.Rename(tmpfile, self)
|
||||
if rerr != nil {
|
||||
a.Logger.Errorln("AgentUpdate() os.Rename():", rerr)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
opts := a.NewCMDOpts()
|
||||
opts.Detached = true
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func NewAgentConfig() *rmm.AgentConfig {
|
|||
customMeshDir, _, _ := k.GetStringValue("MeshDir")
|
||||
natsProxyPath, _, _ := k.GetStringValue("NatsProxyPath")
|
||||
natsProxyPort, _, _ := k.GetStringValue("NatsProxyPort")
|
||||
natsStandardPort, _, _ := k.GetStringValue("NatsStandardPort")
|
||||
|
||||
return &rmm.AgentConfig{
|
||||
BaseURL: baseurl,
|
||||
|
|
@ -76,6 +77,7 @@ func NewAgentConfig() *rmm.AgentConfig {
|
|||
CustomMeshDir: customMeshDir,
|
||||
NatsProxyPath: natsProxyPath,
|
||||
NatsProxyPort: natsProxyPort,
|
||||
NatsStandardPort: natsStandardPort,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ type AgentConfig struct {
|
|||
CustomMeshDir string
|
||||
NatsProxyPath string
|
||||
NatsProxyPort string
|
||||
NatsStandardPort string
|
||||
}
|
||||
|
||||
type RunScriptResp struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue