Watch bool
This commit is contained in:
parent
0a09a78cac
commit
4558270c42
3 changed files with 14 additions and 6 deletions
|
@ -8,6 +8,7 @@ import(
|
||||||
)
|
)
|
||||||
|
|
||||||
type DockerProvider struct {
|
type DockerProvider struct {
|
||||||
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
dockerClient *docker.Client
|
dockerClient *docker.Client
|
||||||
}
|
}
|
||||||
|
@ -15,7 +16,9 @@ type DockerProvider struct {
|
||||||
func (provider *DockerProvider) Provide(serviceChan chan<- *Service){
|
func (provider *DockerProvider) Provide(serviceChan chan<- *Service){
|
||||||
provider.dockerClient, _ = docker.NewClient(provider.Endpoint)
|
provider.dockerClient, _ = docker.NewClient(provider.Endpoint)
|
||||||
dockerEvents := make(chan *docker.APIEvents)
|
dockerEvents := make(chan *docker.APIEvents)
|
||||||
|
if(provider.Watch) {
|
||||||
provider.dockerClient.AddEventListener(dockerEvents)
|
provider.dockerClient.AddEventListener(dockerEvents)
|
||||||
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
event := <-dockerEvents
|
event := <-dockerEvents
|
||||||
|
|
3
file.go
3
file.go
|
@ -10,6 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileProvider struct {
|
type FileProvider struct {
|
||||||
|
Watch bool
|
||||||
Filename string
|
Filename string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,9 @@ func (provider *FileProvider) Provide(serviceChan chan<- *Service){
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if(provider.Watch){
|
||||||
err = watcher.Add(filepath.Dir(file.Name()))
|
err = watcher.Add(filepath.Dir(file.Name()))
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#[docker]
|
[docker]
|
||||||
#endpoint = "unix:///var/run/docker.sock"
|
endpoint = "unix:///var/run/docker.sock"
|
||||||
|
watch = true
|
||||||
|
|
||||||
[file]
|
#[file]
|
||||||
filename = "file.toml"
|
#filename = "file.toml"
|
||||||
|
#watch = true
|
Loading…
Reference in a new issue