ddns/ddns.go

45 lines
883 B
Go
Raw Normal View History

package main
import (
"github.com/pboehm/ddns/backend"
"github.com/pboehm/ddns/frontend"
"github.com/pboehm/ddns/shared"
"github.com/prometheus/client_golang/prometheus"
2017-12-03 23:07:13 +01:00
"golang.org/x/sync/errgroup"
"log"
)
var serviceConfig *shared.Config = &shared.Config{}
func init() {
serviceConfig.Initialize()
2014-07-15 21:48:15 +02:00
}
func main() {
serviceConfig.Validate()
if serviceConfig.Verbose {
log.Printf("Loaded config: %#v", serviceConfig)
}
redis := shared.NewRedisBackend(serviceConfig)
defer redis.Close()
registry := prometheus.NewRegistry()
2017-12-03 23:07:13 +01:00
var group errgroup.Group
group.Go(func() error {
lookup := backend.NewHostLookup(serviceConfig, redis)
return backend.NewBackend(serviceConfig, lookup, registry).Run()
2017-12-03 23:07:13 +01:00
})
2017-12-03 23:07:13 +01:00
group.Go(func() error {
return frontend.NewFrontend(serviceConfig, redis, registry).Run()
2017-12-03 23:07:13 +01:00
})
if err := group.Wait(); err != nil {
log.Fatal(err)
}
}