Periocially check for up to date versions of weave.

This commit is contained in:
Tom Wilkie committed 2016-02-26 15:35:12 +00:00
1 parent 752baa4bd6
commit b228bbb9fb
7 files changed
+50

No files matched your search

+29
View File
@@ -15,6 +15,7 @@ import (
"github.com/gorilla/mux"
"github.com/weaveworks/mesh"
"github.com/weaveworks/go-checkpoint"
. "github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/common/docker"
"github.com/weaveworks/weave/db"
@@ -35,6 +36,32 @@ type dnsConfig struct {
EffectiveListenAddress string
}
const (
signatureFile = "/etc/weave/signature"
versionCheckPeriod = 6 * time.Hour
)
func check() {
handleResponse := func(r *checkpoint.CheckResponse, err error) {
if err != nil {
Log.Printf("Error checking version: %v", err)
} else if r.Outdated {
Log.Printf("Weave version %s is available; please update at %s",
r.CurrentVersion, r.CurrentDownloadURL)
}
}
// Start background version checking
params := checkpoint.CheckParams{
Product: "weave-net",
Version: version,
SignatureFile: signatureFile,
}
resp, err := checkpoint.Check(&params)
handleResponse(resp, err)
checkpoint.CheckInterval(&params, versionCheckPeriod, handleResponse)
}
func main() {
procs := runtime.NumCPU()
// packet sniffing can block an OS thread, so we need one thread
@@ -129,6 +156,8 @@ func main() {
Log.Println("Command line options:", options())
Log.Println("Command line peers:", peers)
go check()
if prof != "" {
p := *profile.CPUProfile
p.ProfilePath = prof