Merge pull request #214 from octoblu/add-frontend-determinism
Deterministic frontend registration
This commit is contained in:
commit
7acc2beae0
1 changed files with 18 additions and 1 deletions
19
server.go
19
server.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/negroni"
|
"github.com/codegangsta/negroni"
|
||||||
"github.com/emilevauge/traefik/middlewares"
|
"github.com/emilevauge/traefik/middlewares"
|
||||||
|
@ -23,6 +24,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
@ -312,7 +314,10 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo
|
||||||
|
|
||||||
backends := map[string]http.Handler{}
|
backends := map[string]http.Handler{}
|
||||||
for _, configuration := range configurations {
|
for _, configuration := range configurations {
|
||||||
for frontendName, frontend := range configuration.Frontends {
|
frontendNames := sortedFrontendNamesForConfig(configuration)
|
||||||
|
for _, frontendName := range frontendNames {
|
||||||
|
frontend := configuration.Frontends[frontendName]
|
||||||
|
|
||||||
log.Debugf("Creating frontend %s", frontendName)
|
log.Debugf("Creating frontend %s", frontendName)
|
||||||
fwd, _ := forward.New(forward.Logger(oxyLogger), forward.PassHostHeader(frontend.PassHostHeader))
|
fwd, _ := forward.New(forward.Logger(oxyLogger), forward.PassHostHeader(frontend.PassHostHeader))
|
||||||
// default endpoints if not defined in frontends
|
// default endpoints if not defined in frontends
|
||||||
|
@ -437,3 +442,15 @@ func (server *Server) buildDefaultHTTPRouter() *mux.Router {
|
||||||
router.NotFoundHandler = http.HandlerFunc(notFoundHandler)
|
router.NotFoundHandler = http.HandlerFunc(notFoundHandler)
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sortedFrontendNamesForConfig(configuration *types.Configuration) []string {
|
||||||
|
keys := []string{}
|
||||||
|
|
||||||
|
for key := range configuration.Frontends {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue