mirror of https://github.com/status-im/consul.git
agent: move update check out of the run method
This commit is contained in:
parent
96d8035adc
commit
84f5e8c3ab
|
@ -465,6 +465,29 @@ func (cmd *Command) checkpointResults(results *checkpoint.CheckResponse, err err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cmd *Command) startupUpdateCheck(config *Config) {
|
||||||
|
version := config.Version
|
||||||
|
if config.VersionPrerelease != "" {
|
||||||
|
version += fmt.Sprintf("-%s", config.VersionPrerelease)
|
||||||
|
}
|
||||||
|
updateParams := &checkpoint.CheckParams{
|
||||||
|
Product: "consul",
|
||||||
|
Version: version,
|
||||||
|
}
|
||||||
|
if !config.DisableAnonymousSignature {
|
||||||
|
updateParams.SignatureFile = filepath.Join(config.DataDir, "checkpoint-signature")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schedule a periodic check with expected interval of 24 hours
|
||||||
|
checkpoint.CheckInterval(updateParams, 24*time.Hour, cmd.checkpointResults)
|
||||||
|
|
||||||
|
// Do an immediate check within the next 30 seconds
|
||||||
|
go func() {
|
||||||
|
time.Sleep(lib.RandomStagger(30 * time.Second))
|
||||||
|
cmd.checkpointResults(checkpoint.Check(updateParams))
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// startupJoin is invoked to handle any joins specified to take place at start time
|
// startupJoin is invoked to handle any joins specified to take place at start time
|
||||||
func (cmd *Command) startupJoin(agent *Agent, cfg *Config) error {
|
func (cmd *Command) startupJoin(agent *Agent, cfg *Config) error {
|
||||||
if len(cfg.StartJoin) == 0 {
|
if len(cfg.StartJoin) == 0 {
|
||||||
|
@ -633,26 +656,7 @@ func (cmd *Command) Run(args []string) int {
|
||||||
|
|
||||||
// Setup update checking
|
// Setup update checking
|
||||||
if !config.DisableUpdateCheck {
|
if !config.DisableUpdateCheck {
|
||||||
version := config.Version
|
cmd.startupUpdateCheck(config)
|
||||||
if config.VersionPrerelease != "" {
|
|
||||||
version += fmt.Sprintf("-%s", config.VersionPrerelease)
|
|
||||||
}
|
|
||||||
updateParams := &checkpoint.CheckParams{
|
|
||||||
Product: "consul",
|
|
||||||
Version: version,
|
|
||||||
}
|
|
||||||
if !config.DisableAnonymousSignature {
|
|
||||||
updateParams.SignatureFile = filepath.Join(config.DataDir, "checkpoint-signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Schedule a periodic check with expected interval of 24 hours
|
|
||||||
checkpoint.CheckInterval(updateParams, 24*time.Hour, cmd.checkpointResults)
|
|
||||||
|
|
||||||
// Do an immediate check within the next 30 seconds
|
|
||||||
go func() {
|
|
||||||
time.Sleep(lib.RandomStagger(30 * time.Second))
|
|
||||||
cmd.checkpointResults(checkpoint.Check(updateParams))
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer agent.Shutdown()
|
defer agent.Shutdown()
|
||||||
|
|
Loading…
Reference in New Issue