зеркало из https://github.com/mozilla/mig.git
Merge pull request #404 from ameihm0912/agtid-path
agent: use path.Join instead of string concat to construct agtid/ok
This commit is contained in:
Коммит
497c5b687e
|
@ -14,6 +14,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -931,11 +932,11 @@ func heartbeat(ctx *Context) (err error) {
|
|||
ctx.Channels.Log <- mig.Log{Desc: desc}.Debug()
|
||||
publish(ctx, mig.Mq_Ex_ToSchedulers, mig.Mq_Q_Heartbeat, body)
|
||||
// update the local heartbeat file
|
||||
err = ioutil.WriteFile(ctx.Agent.RunDir+"mig-agent.ok", []byte(time.Now().String()), 0644)
|
||||
err = ioutil.WriteFile(path.Join(ctx.Agent.RunDir, "mig-agent.ok"), []byte(time.Now().String()), 0644)
|
||||
if err != nil {
|
||||
ctx.Channels.Log <- mig.Log{Desc: "Failed to write mig-agent.ok to disk"}.Err()
|
||||
}
|
||||
os.Chmod(ctx.Agent.RunDir+"mig-agent.ok", 0644)
|
||||
os.Chmod(path.Join(ctx.Agent.RunDir, "mig-agent.ok"), 0644)
|
||||
time.Sleep(ctx.Sleeper)
|
||||
}
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
mrand "math/rand"
|
||||
"mig.ninja/mig"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
@ -222,7 +223,7 @@ func initAgentID(orig_ctx AgentContext) (ctx AgentContext, err error) {
|
|||
logChan <- mig.Log{Desc: "leaving initAgentID()"}.Debug()
|
||||
}()
|
||||
os.Chmod(ctx.RunDir, 0755)
|
||||
idFile := ctx.RunDir + ".migagtid"
|
||||
idFile := path.Join(ctx.RunDir, ".migagtid")
|
||||
id, err := ioutil.ReadFile(idFile)
|
||||
if err != nil {
|
||||
logChan <- mig.Log{Desc: fmt.Sprintf("unable to read agent id from '%s': %v", idFile, err)}.Debug()
|
||||
|
@ -295,7 +296,7 @@ func createIDFile(ctx AgentContext) (id []byte, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
idFile := ctx.RunDir + ".migagtid"
|
||||
idFile := path.Join(ctx.RunDir, ".migagtid")
|
||||
|
||||
// something exists at the location of the id file, just plain remove it
|
||||
_ = os.Remove(idFile)
|
||||
|
|
Загрузка…
Ссылка в новой задаче