Add version check
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
7bf5d557c1
commit
3322e564fd
8 changed files with 121 additions and 6 deletions
|
@ -52,7 +52,7 @@ Run it and forget it!
|
||||||
- Circuit breakers on backends
|
- Circuit breakers on backends
|
||||||
- Round Robin, rebalancer load-balancers
|
- Round Robin, rebalancer load-balancers
|
||||||
- Rest Metrics
|
- Rest Metrics
|
||||||
- [Tiny](https://imagelayers.io/?images=traefik) [official](https://hub.docker.com/r/_/traefik/) docker image included
|
- [Tiny](https://microbadger.com/images/traefik) [official](https://hub.docker.com/r/_/traefik/) docker image included
|
||||||
- SSL backends support
|
- SSL backends support
|
||||||
- SSL frontend support (with SNI)
|
- SSL frontend support (with SNI)
|
||||||
- Clean AngularJS Web UI
|
- Clean AngularJS Web UI
|
||||||
|
|
|
@ -25,6 +25,7 @@ type TraefikConfiguration struct {
|
||||||
type GlobalConfiguration struct {
|
type GlobalConfiguration struct {
|
||||||
GraceTimeOut int64 `short:"g" description:"Duration to give active requests a chance to finish during hot-reload"`
|
GraceTimeOut int64 `short:"g" description:"Duration to give active requests a chance to finish during hot-reload"`
|
||||||
Debug bool `short:"d" description:"Enable debug mode"`
|
Debug bool `short:"d" description:"Enable debug mode"`
|
||||||
|
CheckNewVersion bool `description:"Periodically check if a new version has been released"`
|
||||||
AccessLogsFile string `description:"Access logs file"`
|
AccessLogsFile string `description:"Access logs file"`
|
||||||
TraefikLogsFile string `description:"Traefik logs file"`
|
TraefikLogsFile string `description:"Traefik logs file"`
|
||||||
LogLevel string `short:"l" description:"Log level"`
|
LogLevel string `short:"l" description:"Log level"`
|
||||||
|
@ -409,6 +410,7 @@ func NewTraefikConfiguration() *TraefikConfiguration {
|
||||||
DefaultEntryPoints: []string{},
|
DefaultEntryPoints: []string{},
|
||||||
ProvidersThrottleDuration: time.Duration(2 * time.Second),
|
ProvidersThrottleDuration: time.Duration(2 * time.Second),
|
||||||
MaxIdleConnsPerHost: 200,
|
MaxIdleConnsPerHost: 200,
|
||||||
|
CheckNewVersion: true,
|
||||||
},
|
},
|
||||||
ConfigFile: "",
|
ConfigFile: "",
|
||||||
}
|
}
|
||||||
|
|
22
docs/toml.md
22
docs/toml.md
|
@ -9,6 +9,28 @@
|
||||||
# Global configuration
|
# Global configuration
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
|
# Timeout in seconds.
|
||||||
|
# Duration to give active requests a chance to finish during hot-reloads
|
||||||
|
#
|
||||||
|
# Optional
|
||||||
|
# Default: 10
|
||||||
|
#
|
||||||
|
# graceTimeOut = 10
|
||||||
|
|
||||||
|
# Enable debug mode
|
||||||
|
#
|
||||||
|
# Optional
|
||||||
|
# Default: false
|
||||||
|
#
|
||||||
|
# debug = true
|
||||||
|
|
||||||
|
# Periodically check if a new version has been released
|
||||||
|
#
|
||||||
|
# Optional
|
||||||
|
# Default: true
|
||||||
|
#
|
||||||
|
# checkNewVersion = false
|
||||||
|
|
||||||
# Traefik logs file
|
# Traefik logs file
|
||||||
# If not defined, logs to stdout
|
# If not defined, logs to stdout
|
||||||
#
|
#
|
||||||
|
|
10
glide.lock
generated
10
glide.lock
generated
|
@ -1,5 +1,5 @@
|
||||||
hash: 45d9abd00276bba5aaeb92cd5f2464e404bba3cf90f37aa538d4866041626327
|
hash: d2bb370ffd3c0b528587581bc77d900c98921c02df581594bf19655968aa9849
|
||||||
updated: 2016-10-26T14:26:07.740582437+02:00
|
updated: 2016-10-27T15:54:07.397981259+02:00
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/abbot/go-http-auth
|
- name: github.com/abbot/go-http-auth
|
||||||
version: cb4372376e1e00e9f6ab9ec142e029302c9e7140
|
version: cb4372376e1e00e9f6ab9ec142e029302c9e7140
|
||||||
|
@ -168,6 +168,10 @@ imports:
|
||||||
- proto
|
- proto
|
||||||
- name: github.com/golang/glog
|
- name: github.com/golang/glog
|
||||||
version: fca8c8854093a154ff1eb580aae10276ad6b1b5f
|
version: fca8c8854093a154ff1eb580aae10276ad6b1b5f
|
||||||
|
- name: github.com/google/go-github
|
||||||
|
version: ed33550bbf49ddffcc36e1309d3f58ed0b6c2305
|
||||||
|
subpackages:
|
||||||
|
- github
|
||||||
- name: github.com/google/go-querystring
|
- name: github.com/google/go-querystring
|
||||||
version: 9235644dd9e52eeae6fa48efd539fdc351a0af53
|
version: 9235644dd9e52eeae6fa48efd539fdc351a0af53
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -180,6 +184,8 @@ imports:
|
||||||
- api
|
- api
|
||||||
- name: github.com/hashicorp/go-cleanhttp
|
- name: github.com/hashicorp/go-cleanhttp
|
||||||
version: ad28ea4487f05916463e2423a55166280e8254b5
|
version: ad28ea4487f05916463e2423a55166280e8254b5
|
||||||
|
- name: github.com/hashicorp/go-version
|
||||||
|
version: deeb027c13a95d56c7585df3fe29207208c6706e
|
||||||
- name: github.com/hashicorp/serf
|
- name: github.com/hashicorp/serf
|
||||||
version: b03bf85930b2349eb04b97c8fac437495296e3e7
|
version: b03bf85930b2349eb04b97c8fac437495296e3e7
|
||||||
subpackages:
|
subpackages:
|
||||||
|
|
|
@ -107,4 +107,6 @@ import:
|
||||||
- package: github.com/coreos/go-systemd
|
- package: github.com/coreos/go-systemd
|
||||||
version: v12
|
version: v12
|
||||||
subpackages:
|
subpackages:
|
||||||
- daemon
|
- daemon
|
||||||
|
- package: github.com/google/go-github
|
||||||
|
- package: github.com/hashicorp/go-version
|
19
traefik.go
19
traefik.go
|
@ -11,6 +11,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/containous/flaeg"
|
"github.com/containous/flaeg"
|
||||||
|
@ -20,12 +21,12 @@ import (
|
||||||
"github.com/containous/traefik/log"
|
"github.com/containous/traefik/log"
|
||||||
"github.com/containous/traefik/middlewares"
|
"github.com/containous/traefik/middlewares"
|
||||||
"github.com/containous/traefik/provider"
|
"github.com/containous/traefik/provider"
|
||||||
|
"github.com/containous/traefik/safe"
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"github.com/containous/traefik/version"
|
"github.com/containous/traefik/version"
|
||||||
|
"github.com/coreos/go-systemd/daemon"
|
||||||
"github.com/docker/libkv/store"
|
"github.com/docker/libkv/store"
|
||||||
"github.com/satori/go.uuid"
|
"github.com/satori/go.uuid"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/daemon"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var versionTemplate = `Version: {{.Version}}
|
var versionTemplate = `Version: {{.Version}}
|
||||||
|
@ -263,6 +264,20 @@ func run(traefikConfiguration *TraefikConfiguration) {
|
||||||
}
|
}
|
||||||
jsonConf, _ := json.Marshal(globalConfiguration)
|
jsonConf, _ := json.Marshal(globalConfiguration)
|
||||||
log.Infof("Traefik version %s built on %s", version.Version, version.BuildDate)
|
log.Infof("Traefik version %s built on %s", version.Version, version.BuildDate)
|
||||||
|
|
||||||
|
if globalConfiguration.CheckNewVersion {
|
||||||
|
ticker := time.NewTicker(24 * time.Hour)
|
||||||
|
safe.Go(func() {
|
||||||
|
version.CheckNewVersion()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
version.CheckNewVersion()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if len(traefikConfiguration.ConfigFile) != 0 {
|
if len(traefikConfiguration.ConfigFile) != 0 {
|
||||||
log.Infof("Using TOML configuration file %s", traefikConfiguration.ConfigFile)
|
log.Infof("Using TOML configuration file %s", traefikConfiguration.ConfigFile)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,20 @@
|
||||||
#
|
#
|
||||||
# graceTimeOut = 10
|
# graceTimeOut = 10
|
||||||
|
|
||||||
|
# Enable debug mode
|
||||||
|
#
|
||||||
|
# Optional
|
||||||
|
# Default: false
|
||||||
|
#
|
||||||
|
# debug = true
|
||||||
|
|
||||||
|
# Periodically check if a new version has been released
|
||||||
|
#
|
||||||
|
# Optional
|
||||||
|
# Default: true
|
||||||
|
#
|
||||||
|
# checkNewVersion = false
|
||||||
|
|
||||||
# Traefik logs file
|
# Traefik logs file
|
||||||
# If not defined, logs to stdout
|
# If not defined, logs to stdout
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package version
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/containous/traefik/log"
|
||||||
|
"github.com/google/go-github/github"
|
||||||
|
goversion "github.com/hashicorp/go-version"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Version holds the current version of traefik.
|
// Version holds the current version of traefik.
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
|
@ -8,3 +15,50 @@ var (
|
||||||
// BuildDate holds the build date of traefik.
|
// BuildDate holds the build date of traefik.
|
||||||
BuildDate = "I don't remember exactly"
|
BuildDate = "I don't remember exactly"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CheckNewVersion checks if a new version is available
|
||||||
|
func CheckNewVersion() {
|
||||||
|
if Version == "dev" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
updateURL, err := url.Parse("https://update.traefik.io")
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Error checking new version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client.BaseURL = updateURL
|
||||||
|
releases, resp, err := client.Repositories.ListReleases("containous", "traefik", nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Error checking new version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
log.Warnf("Error checking new version: status=%s", resp.Status)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentVersion, err := goversion.NewVersion(Version)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Error checking new version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, release := range releases {
|
||||||
|
releaseVersion, err := goversion.NewVersion(*release.TagName)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Error checking new version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(currentVersion.Prerelease()) == 0 && len(releaseVersion.Prerelease()) > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if releaseVersion.GreaterThan(currentVersion) {
|
||||||
|
log.Warnf("A new release has been found: %s. Please consider updating.", releaseVersion.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue