log info about TOML configuration file using
+glide update flaeg & staert +fix README.md +fix configFile flag description Signed-off-by: Martin <martin.piegay@zenika.com>
This commit is contained in:
parent
aad5f52968
commit
d8ad30f38a
5 changed files with 28 additions and 17 deletions
|
@ -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:
|
||||
|
|
|
@ -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.).
|
||||
|
|
8
glide.lock
generated
8
glide.lock
generated
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
29
traefik.go
29
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() {
|
||||
|
|
Loading…
Reference in a new issue