Files
weave/main.go
T
Michael Bridgen 0749460652 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.
2014-10-16 15:38:32 +01:00

41 lines
1.1 KiB
Go

package main
import (
"flag"
"github.com/zettio/weavedns/server"
"log"
)
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()
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)
}
}