Moved updater into server
While we're only reacting to containers going away, it's more convenient to bundle the docker events watcher into the server. I've added a flag to switch it on; and switched it on by default in the container. I also implemented `Zone.DeleteRecordsFor(ident)`, which removes all records for a particular container. One minor change to the structure of the code is that the Zone is now constructed *outside* the server, and given to it and the updater.
This commit is contained in:
1 parent
0fb4bce24d
commit
0749460652
9 files changed
+102
-72
No files matched your search
@@ -9,18 +9,31 @@ import (
|
||||
func main() {
|
||||
var (
|
||||
ifaceName string
|
||||
apiPath string
|
||||
dnsPort int
|
||||
httpPort int
|
||||
wait int
|
||||
watch bool
|
||||
)
|
||||
|
||||
flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast")
|
||||
flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "Path to Docker API socket")
|
||||
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up (defaults to 0)")
|
||||
flag.IntVar(&dnsPort, "dnsport", 53, "port to listen to dns requests (defaults to 53)")
|
||||
flag.IntVar(&httpPort, "httpport", 6785, "port to listen to HTTP requests (defaults to 6785)")
|
||||
flag.BoolVar(&watch, "watch", false, "watch the docker socket for container events")
|
||||
flag.Parse()
|
||||
|
||||
err := weavedns.StartServer(ifaceName, dnsPort, httpPort, wait)
|
||||
var zone = new(weavedns.ZoneDb)
|
||||
|
||||
if watch {
|
||||
err := weavedns.StartUpdater(apiPath, zone)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to start watcher", err)
|
||||
}
|
||||
}
|
||||
|
||||
err := weavedns.StartServer(zone, ifaceName, dnsPort, httpPort, wait)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to start server: %s", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user