Revert "Background updates for names in the Zone database"

This commit is contained in:
Alvaro committed 2015-05-26 12:56:44 +02:00
1 parent 5382037c4e
commit 21a1cd0469
19 files changed
+467 -2460

No files matched your search

+33 -61
View File
@@ -15,24 +15,19 @@ var version = "(unreleased version)"
func main() {
var (
justVersion bool
ifaceName string
apiPath string
domain string
dnsPort int
httpPort int
wait int
timeout int
udpbuf int
refreshInterval int
refreshWorkers int
relevantTime int
maxAnswers int
cacheLen int
cacheDisabled bool
watch bool
debug bool
err error
justVersion bool
ifaceName string
apiPath string
domain string
dnsPort int
httpPort int
wait int
timeout int
udpbuf int
cacheLen int
watch bool
debug bool
err error
)
flag.BoolVar(&justVersion, "version", false, "print version and exit")
@@ -42,18 +37,11 @@ func main() {
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up")
flag.IntVar(&dnsPort, "dnsport", weavedns.DefaultServerPort, "port to listen to DNS requests")
flag.IntVar(&httpPort, "httpport", 6785, "port to listen to HTTP requests")
flag.IntVar(&timeout, "timeout", weavedns.DefaultTimeout, "timeout for resolutions")
flag.IntVar(&udpbuf, "udpbuf", weavedns.DefaultUDPBuflen, "UDP buffer length")
flag.IntVar(&cacheLen, "cache", weavedns.DefaultCacheLen, "cache length")
flag.BoolVar(&watch, "watch", true, "watch the docker socket for container events")
flag.BoolVar(&debug, "debug", false, "output debugging info to stderr")
// advanced options
flag.IntVar(&refreshInterval, "refresh", weavedns.DefaultRefreshInterval, "refresh interval (in secs) for local names (0=disable)")
flag.IntVar(&refreshWorkers, "refresh-workers", weavedns.DefaultNumUpdaters, "default number of background updaters")
flag.IntVar(&maxAnswers, "max-answers", weavedns.DefaultMaxAnswers, "maximum number of answers returned to clients (0=unlimited)")
flag.IntVar(&relevantTime, "relevant", weavedns.DefaultRelevantTime, "life time for info in the absence of queries (in secs)")
flag.IntVar(&udpbuf, "udpbuf", weavedns.DefaultUDPBuflen, "UDP buffer length")
flag.IntVar(&timeout, "timeout", weavedns.DefaultTimeout, "timeout for resolutions (in millisecs)")
flag.BoolVar(&cacheDisabled, "no-cache", false, "disable the cache")
flag.Parse()
if justVersion {
@@ -62,7 +50,16 @@ func main() {
}
InitDefaultLogging(debug)
Info.Printf("[main] WeaveDNS version %s\n", version) // first thing in log: the version
Info.Printf("WeaveDNS version %s\n", version) // first thing in log: the version
var zone = weavedns.NewZoneDb(domain)
if watch {
err := updater.Start(apiPath, zone)
if err != nil {
Error.Fatal("Unable to start watcher", err)
}
}
var iface *net.Interface
if ifaceName != "" {
@@ -76,44 +73,19 @@ func main() {
}
}
zoneConfig := weavedns.ZoneConfig{
Domain: domain,
Iface: iface,
RefreshInterval: refreshInterval,
RefreshWorkers: refreshWorkers,
RelevantTime: relevantTime,
}
zone, err := weavedns.NewZoneDb(zoneConfig)
if err != nil {
Error.Fatal("[main] Unable to initialize the Zone database", err)
}
err = zone.Start()
if err != nil {
Error.Fatal("[main] Unable to start the Zone database", err)
}
defer zone.Stop()
if watch {
err := updater.Start(apiPath, zone)
if err != nil {
Error.Fatal("[main] Unable to start watcher", err)
}
}
srvConfig := weavedns.DNSServerConfig{
Zone: zone,
Port: dnsPort,
CacheLen: cacheLen,
MaxAnswers: maxAnswers,
Timeout: timeout,
UDPBufLen: udpbuf,
CacheDisabled: cacheDisabled,
Port: dnsPort,
CacheLen: cacheLen,
LocalDomain: domain,
Timeout: timeout,
UDPBufLen: udpbuf,
}
srv, err := weavedns.NewDNSServer(srvConfig)
srv, err := weavedns.NewDNSServer(srvConfig, zone, iface)
if err != nil {
Error.Fatal("[main] Failed to initialize the WeaveDNS server", err)
Error.Fatal("Failed to initialize the WeaveDNS server", err)
}
Info.Println("Upstream", srv.Upstream)
go SignalHandlerLoop(srv)
go weavedns.ListenHTTP(version, srv, domain, zone, httpPort)