From d8ad30f38ab843b35098f0ef9f0b42909f7e09eb Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 30 May 2016 11:37:12 +0200 Subject: [PATCH] log info about TOML configuration file using +glide update flaeg & staert +fix README.md +fix configFile flag description Signed-off-by: Martin --- README.md | 2 +- configuration.go | 2 +- glide.lock | 8 ++++---- glide.yaml | 4 ++-- traefik.go | 29 ++++++++++++++++++++--------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 684f164fc..e16bb35a9 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ You can access to a simple HTML frontend of Træfik. - The simple way: grab the latest binary from the [releases](https://github.com/containous/traefik/releases) page and just run it with the [sample configuration file](https://raw.githubusercontent.com/containous/traefik/master/traefik.sample.toml): ```shell -./traefik -c traefik.toml +./traefik --configFile=traefik.toml ``` - Use the tiny Docker image: diff --git a/configuration.go b/configuration.go index 72703e177..9949d3cf3 100644 --- a/configuration.go +++ b/configuration.go @@ -14,7 +14,7 @@ import ( // TraefikConfiguration holds GlobalConfiguration and other stuff type TraefikConfiguration struct { GlobalConfiguration - ConfigFile string `short:"c" description:"Timeout in seconds. Duration to give active requests a chance to finish during hot-reloads"` + ConfigFile string `short:"c" description:"Configuration file to use (TOML)."` } // GlobalConfiguration holds global configuration (with providers, etc.). diff --git a/glide.lock b/glide.lock index cd8969fca..cdc1a522d 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 660249b4d5cbcfd0cb0a2d9d39ce798ec8df7d3277c53ed4043fe2f61b29eeb9 -updated: 2016-05-27T09:59:17.855890752+02:00 +hash: 1d42530971835a5a1e593e8efc54f28f2714cb8d1dfcb333e3b9ba92ef1917cc +updated: 2016-05-30T16:53:17.058435869+02:00 imports: - name: github.com/boltdb/bolt version: dfb21201d9270c1082d5fb0f07f500311ff72f18 @@ -18,7 +18,7 @@ imports: - name: github.com/codegangsta/negroni version: ffbc66b612ee3eac2eba29aedce4c3a65e4dd0a1 - name: github.com/containous/flaeg - version: c425b9d758df1864ca838dbd433f1cf8f5097d51 + version: a208db24c0e580be76efed167736fe3204c7c954 - name: github.com/containous/oxy version: 183212964e13e7b8afe01a08b193d04300554a68 subpackages: @@ -29,7 +29,7 @@ imports: - stream - utils - name: github.com/containous/staert - version: ff272631ecfc9c22490b651fea0f08d364d46518 + version: 9f815ef829b66de3519fea6c0b8d4708eb9472d4 - name: github.com/coreos/etcd version: c400d05d0aa73e21e431c16145e558d624098018 subpackages: diff --git a/glide.yaml b/glide.yaml index d64ed3c4c..38d0ae099 100644 --- a/glide.yaml +++ b/glide.yaml @@ -8,7 +8,7 @@ import: - package: github.com/cenkalti/backoff - package: github.com/codegangsta/negroni - package: github.com/containous/flaeg - version: c425b9d758df1864ca838dbd433f1cf8f5097d51 + version: a208db24c0e580be76efed167736fe3204c7c954 - package: github.com/containous/oxy subpackages: - cbreaker @@ -18,7 +18,7 @@ import: - stream - utils - package: github.com/containous/staert - version: ff272631ecfc9c22490b651fea0f08d364d46518 + version: 9f815ef829b66de3519fea6c0b8d4708eb9472d4 - package: github.com/docker/engine-api version: 3d3d0b6c9d2651aac27f416a6da0224c1875b3eb subpackages: diff --git a/traefik.go b/traefik.go index a313c6466..5fef4bc08 100644 --- a/traefik.go +++ b/traefik.go @@ -73,15 +73,9 @@ Complete documentation is available at https://traefik.io`, if _, err := s.LoadConfig(); err != nil { fmtlog.Println(err) } - if traefikConfiguration.File != nil && len(traefikConfiguration.File.Filename) == 0 { - // no filename, setting to global config file - log.Debugf("ConfigFileUsed %s", toml.ConfigFileUsed()) - traefikConfiguration.File.Filename = toml.ConfigFileUsed() - } - if len(traefikConfiguration.EntryPoints) == 0 { - traefikConfiguration.EntryPoints = map[string]*EntryPoint{"http": {Address: ":80"}} - traefikConfiguration.DefaultEntryPoints = []string{"http"} - } + + traefikConfiguration.ConfigFile = toml.ConfigFileUsed() + if err := s.Run(); err != nil { fmtlog.Println(err) os.Exit(-1) @@ -107,6 +101,23 @@ func run(traefikConfiguration *TraefikConfiguration) { } log.SetLevel(level) + if len(traefikConfiguration.ConfigFile) != 0 { + log.Infof("Using TOML configuration file %s", traefikConfiguration.ConfigFile) + } + if traefikConfiguration.File != nil && len(traefikConfiguration.File.Filename) == 0 { + // no filename, setting to global config file + if len(traefikConfiguration.ConfigFile) != 0 { + traefikConfiguration.File.Filename = traefikConfiguration.ConfigFile + } else { + log.Errorln("Error using file configuration backend, no filename defined") + } + } + + if len(traefikConfiguration.EntryPoints) == 0 { + traefikConfiguration.EntryPoints = map[string]*EntryPoint{"http": {Address: ":80"}} + traefikConfiguration.DefaultEntryPoints = []string{"http"} + } + if len(globalConfiguration.TraefikLogsFile) > 0 { fi, err := os.OpenFile(globalConfiguration.TraefikLogsFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) defer func() {