mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
agent: Add version to info output
This commit is contained in:
parent
a5f05fa902
commit
42e3729a7c
@ -514,6 +514,16 @@ func (a *Agent) Stats() map[string]map[string]string {
|
|||||||
"checks": toString(uint64(len(a.state.checks))),
|
"checks": toString(uint64(len(a.state.checks))),
|
||||||
"services": toString(uint64(len(a.state.services))),
|
"services": toString(uint64(len(a.state.services))),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revision := a.config.Revision
|
||||||
|
if len(revision) > 8 {
|
||||||
|
revision = revision[:8]
|
||||||
|
}
|
||||||
|
stats["build"] = map[string]string{
|
||||||
|
"revision": revision,
|
||||||
|
"version": a.config.Version,
|
||||||
|
"prerelease": a.config.VersionPrerelease,
|
||||||
|
}
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +25,17 @@ var gracefulTimeout = 5 * time.Second
|
|||||||
// ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly
|
// ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly
|
||||||
// exit.
|
// exit.
|
||||||
type Command struct {
|
type Command struct {
|
||||||
Ui cli.Ui
|
Revision string
|
||||||
ShutdownCh <-chan struct{}
|
Version string
|
||||||
args []string
|
VersionPrerelease string
|
||||||
logFilter *logutils.LevelFilter
|
Ui cli.Ui
|
||||||
agent *Agent
|
ShutdownCh <-chan struct{}
|
||||||
rpcServer *AgentRPC
|
args []string
|
||||||
httpServer *HTTPServer
|
logFilter *logutils.LevelFilter
|
||||||
dnsServer *DNSServer
|
agent *Agent
|
||||||
|
rpcServer *AgentRPC
|
||||||
|
httpServer *HTTPServer
|
||||||
|
dnsServer *DNSServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// readConfig is responsible for setup of our configuration using
|
// readConfig is responsible for setup of our configuration using
|
||||||
@ -124,6 +127,11 @@ func (c *Command) readConfig() *Config {
|
|||||||
c.Ui.Error("WARNING: Windows is not recommended as a Consul server. Do not use in production.")
|
c.Ui.Error("WARNING: Windows is not recommended as a Consul server. Do not use in production.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the version info
|
||||||
|
config.Revision = c.Revision
|
||||||
|
config.Version = c.Version
|
||||||
|
config.VersionPrerelease = c.VersionPrerelease
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,15 @@ type Config struct {
|
|||||||
|
|
||||||
// ConsulConfig can either be provided or a default one created
|
// ConsulConfig can either be provided or a default one created
|
||||||
ConsulConfig *consul.Config `mapstructure:"-" json:"-"`
|
ConsulConfig *consul.Config `mapstructure:"-" json:"-"`
|
||||||
|
|
||||||
|
// Revision is the GitCommit this maps to
|
||||||
|
Revision string `mapstructure:"-"`
|
||||||
|
|
||||||
|
// Version is the release version number
|
||||||
|
Version string `mapstructure:"-"`
|
||||||
|
|
||||||
|
// VersionPrerelease is a label for pre-release builds
|
||||||
|
VersionPrerelease string `mapstructure:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type dirEnts []os.FileInfo
|
type dirEnts []os.FileInfo
|
||||||
|
@ -17,8 +17,11 @@ func init() {
|
|||||||
Commands = map[string]cli.CommandFactory{
|
Commands = map[string]cli.CommandFactory{
|
||||||
"agent": func() (cli.Command, error) {
|
"agent": func() (cli.Command, error) {
|
||||||
return &agent.Command{
|
return &agent.Command{
|
||||||
Ui: ui,
|
Revision: GitCommit,
|
||||||
ShutdownCh: make(chan struct{}),
|
Version: Version,
|
||||||
|
VersionPrerelease: VersionPrerelease,
|
||||||
|
Ui: ui,
|
||||||
|
ShutdownCh: make(chan struct{}),
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user