Is Watching?
This commit is contained in:
parent
be179e6b68
commit
f5ea23ed2b
2 changed files with 25 additions and 23 deletions
20
docker.go
20
docker.go
|
@ -48,17 +48,17 @@ func (provider *DockerProvider) Provide(configurationChan chan <- *Configuration
|
||||||
dockerEvents := make(chan *docker.APIEvents)
|
dockerEvents := make(chan *docker.APIEvents)
|
||||||
if (provider.Watch) {
|
if (provider.Watch) {
|
||||||
provider.dockerClient.AddEventListener(dockerEvents)
|
provider.dockerClient.AddEventListener(dockerEvents)
|
||||||
}
|
go func() {
|
||||||
go func() {
|
for {
|
||||||
for {
|
event := <-dockerEvents
|
||||||
event := <-dockerEvents
|
log.Println("Docker event receveived", event)
|
||||||
log.Println("Docker event receveived", event)
|
configuration := provider.loadDockerConfig()
|
||||||
configuration := provider.loadDockerConfig()
|
if (configuration != nil) {
|
||||||
if (configuration != nil) {
|
configurationChan <- configuration
|
||||||
configurationChan <- configuration
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
}()
|
}
|
||||||
|
|
||||||
configuration := provider.loadDockerConfig()
|
configuration := provider.loadDockerConfig()
|
||||||
configurationChan <- configuration
|
configurationChan <- configuration
|
||||||
|
|
28
marathon.go
28
marathon.go
|
@ -46,20 +46,22 @@ func (provider *MarathonProvider) Provide(configurationChan chan <- *Configurati
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
provider.marathonClient = client
|
provider.marathonClient = client
|
||||||
update := make(marathon.EventsChannel,5)
|
update := make(marathon.EventsChannel, 5)
|
||||||
if err := client.AddEventsListener(update, marathon.EVENTS_APPLICATIONS); err != nil {
|
if (provider.Watch) {
|
||||||
log.Println("Failed to register for subscriptions, %s", err)
|
if err := client.AddEventsListener(update, marathon.EVENTS_APPLICATIONS); err != nil {
|
||||||
} else {
|
log.Println("Failed to register for subscriptions, %s", err)
|
||||||
go func() {
|
} else {
|
||||||
for {
|
go func() {
|
||||||
event := <-update
|
for {
|
||||||
log.Println("Marathon event receveived", event)
|
event := <-update
|
||||||
configuration := provider.loadMarathonConfig()
|
log.Println("Marathon event receveived", event)
|
||||||
if (configuration != nil) {
|
configuration := provider.loadMarathonConfig()
|
||||||
configurationChan <- configuration
|
if (configuration != nil) {
|
||||||
|
configurationChan <- configuration
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
}()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration := provider.loadMarathonConfig()
|
configuration := provider.loadMarathonConfig()
|
||||||
|
|
Loading…
Reference in a new issue