Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log info about TOML configuration file using #420

Merged
merged 1 commit into from
May 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.).
Expand Down
8 changes: 4 additions & 4 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
29 changes: 20 additions & 9 deletions traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down