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