Marathon provider listener
This commit is contained in:
parent
9a840d1904
commit
3dd168b465
3 changed files with 19 additions and 4 deletions
|
@ -52,7 +52,7 @@ func (provider *DockerProvider) Provide(configurationChan chan <- *Configuration
|
|||
go func() {
|
||||
for {
|
||||
event := <-dockerEvents
|
||||
log.Println("Event receveived", event)
|
||||
log.Println("Docker event receveived", event)
|
||||
configuration := provider.loadDockerConfig()
|
||||
if (configuration != nil) {
|
||||
configurationChan <- configuration
|
||||
|
|
19
marathon.go
19
marathon.go
|
@ -40,11 +40,28 @@ var MarathonFuncMap = template.FuncMap{
|
|||
func (provider *MarathonProvider) Provide(configurationChan chan <- *Configuration) {
|
||||
config := marathon.NewDefaultConfig()
|
||||
config.URL = provider.Endpoint
|
||||
config.EventsInterface = "docker0"
|
||||
if client, err := marathon.NewClient(config); err != nil {
|
||||
log.Println("Failed to create a client for marathon, error: %s", err)
|
||||
return
|
||||
} else {
|
||||
provider.marathonClient = client
|
||||
update := make(marathon.EventsChannel,5)
|
||||
if err := client.AddEventsListener(update, marathon.EVENTS_APPLICATIONS); err != nil {
|
||||
log.Println("Failed to register for subscriptions, %s", err)
|
||||
} else {
|
||||
go func() {
|
||||
for {
|
||||
event := <-update
|
||||
log.Println("Marathon event receveived", event)
|
||||
configuration := provider.loadMarathonConfig()
|
||||
if (configuration != nil) {
|
||||
configurationChan <- configuration
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
configuration := provider.loadMarathonConfig()
|
||||
configurationChan <- configuration
|
||||
}
|
||||
|
@ -94,7 +111,5 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Println(buffer.String())
|
||||
|
||||
return configuration
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
[routes]{{range .Applications}}
|
||||
[routes.route{{.ID | replace "/" "-"}}]
|
||||
backend = ".backend{{.ID | replace "/" "-"}}"
|
||||
backend = "backend{{.ID | replace "/" "-"}}"
|
||||
[routes.route-{{getHost .}}.rules.rule-host-{{getHost .}}]
|
||||
category = "Host"
|
||||
value = "{{getHost .}}.{{$.Domain}}"
|
||||
|
|
Loading…
Reference in a new issue