Move files around in preparation for melding into weave code

* library code will go in weave/nameserver/
 * main.go for the server goes in weavedns/ with the containerising
This commit is contained in:
Michael Bridgen committed 2014-10-29 11:34:56 +00:00
1 parent fdcb960cdd
commit 8469fea215
17 files changed

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package weavedns
import (
"github.com/fsouza/go-dockerclient"
)
func StartUpdater(apiPath string, zone Zone) error {
client, err := docker.NewClient(apiPath)
if err != nil {
Error.Fatalf("Unable to connect to Docker API on %s: %s", apiPath, err)
}
events := make(chan *docker.APIEvents)
client.AddEventListener(events)
Info.Printf("Using Docker API on %s", apiPath)
go func() {
for event := range events {
handleEvent(zone, event, client)
}
}()
return nil
}
func handleEvent(zone Zone, event *docker.APIEvents, client *docker.Client) error {
switch event.Status {
case "die":
id := event.ID
Info.Printf("Container %s down. Removing records", id)
zone.DeleteRecordsFor(id)
}
return nil
}