-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (31 loc) · 1.22 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"flag"
log "github.com/sirupsen/logrus"
"github.com/tcardonne/restic-controller/conf"
"github.com/tcardonne/restic-controller/controller"
"github.com/tcardonne/restic-controller/exporter"
)
func main() {
configFile := flag.String("config", "config.yml", "Specify a configuration file to load")
flag.Parse()
config, err := conf.LoadConfiguration(*configFile)
if err != nil {
log.WithField("err", err).Fatal("Failed to load configuration")
}
if err := conf.ConfigureLogging(&config.Log); err != nil {
log.WithField("err", err).Fatal("Failed to configure logging")
}
integrityController := controller.NewIntegrityController(config.Repositories)
retentionController := controller.NewRetentionController(config.Repositories)
exp := exporter.NewExporter(config.Exporter, config.Repositories, integrityController, retentionController)
if err := integrityController.Start(); err != nil {
log.WithField("err", err).Fatal("Failed to start integrity controller")
}
if err := retentionController.Start(); err != nil {
log.WithField("err", err).Fatal("Failed to start retention controller")
}
if err := exp.ListenAndServe(); err != nil {
log.WithField("err", err).Fatal("Failed starting http server")
}
}