зеркало из https://github.com/mozilla/mig.git
[minor] add support for custom tags in agent conf
This commit is contained in:
Родитель
0926c738d3
Коммит
2b9ecda3cf
|
@ -16,6 +16,14 @@ import(
|
|||
_ "mig/modules/example"
|
||||
)
|
||||
|
||||
// some tags that are useful to differentiate agents. You can add whatever
|
||||
// you want in this struct, it will be sent by the agent in each heartbeat
|
||||
var TAGS = struct {
|
||||
Operator string `json:"operator"`
|
||||
}{
|
||||
"MyFavoriteAdminTeam",
|
||||
}
|
||||
|
||||
// restart the agent on failures, don't let it die
|
||||
var ISIMMORTAL bool = true
|
||||
|
||||
|
|
|
@ -14,18 +14,19 @@ import (
|
|||
// Agent stores the description of an agent and serves as a canvas
|
||||
// for heartbeat messages
|
||||
type Agent struct {
|
||||
ID float64 `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
QueueLoc string `json:"queueloc"`
|
||||
OS string `json:"os,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
StartTime time.Time `json:"starttime,omitempty"`
|
||||
DestructionTime time.Time `json:"destructiontime,omitempty"`
|
||||
HeartBeatTS time.Time `json:"heartbeatts,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Authorized bool `json:"authorized,omitempty"`
|
||||
Env AgentEnv `json:"environment,omitempty"`
|
||||
ID float64 `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
QueueLoc string `json:"queueloc"`
|
||||
OS string `json:"os,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
StartTime time.Time `json:"starttime,omitempty"`
|
||||
DestructionTime time.Time `json:"destructiontime,omitempty"`
|
||||
HeartBeatTS time.Time `json:"heartbeatts,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Authorized bool `json:"authorized,omitempty"`
|
||||
Env AgentEnv `json:"environment,omitempty"`
|
||||
Tags interface{} `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// AgentEnv stores basic information of the endpoint
|
||||
|
|
|
@ -531,6 +531,7 @@ func heartbeat(ctx Context) (err error) {
|
|||
QueueLoc: ctx.Agent.QueueLoc,
|
||||
StartTime: time.Now(),
|
||||
Env: ctx.Agent.Env,
|
||||
Tags: ctx.Agent.Tags,
|
||||
}
|
||||
|
||||
// loop forever
|
||||
|
|
|
@ -35,6 +35,7 @@ type Context struct {
|
|||
Hostname, OS, QueueLoc, UID, BinPath, RunDir string
|
||||
Respawn bool
|
||||
Env mig.AgentEnv
|
||||
Tags interface{}
|
||||
}
|
||||
Channels struct {
|
||||
// internal
|
||||
|
@ -75,6 +76,7 @@ func Init(foreground, upgrade bool) (ctx Context, err error) {
|
|||
}
|
||||
ctx.Channels.Log <- mig.Log{Desc: "leaving initAgent()"}.Debug()
|
||||
}()
|
||||
ctx.Agent.Tags = TAGS
|
||||
|
||||
ctx.Logging, err = mig.InitLogger(LOGGINGCONF, "mig-agent")
|
||||
if err != nil {
|
||||
|
|
Загрузка…
Ссылка в новой задаче