-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
60 lines (46 loc) · 1.21 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"context"
"flag"
"os"
"github.com/cryp-com-br/pg-syncer/config"
"github.com/cryp-com-br/pg-syncer/repository"
"github.com/cryp-com-br/pg-syncer/syncer"
log "github.com/sirupsen/logrus"
)
func init() {
dev := flag.Bool("dev", false, "Set the environment to dev.")
trace := flag.Bool("trace", false, "Enable trace.")
flag.Parse()
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
log.SetOutput(os.Stdout)
log.SetLevel(log.InfoLevel)
if *dev {
log.SetLevel(log.DebugLevel)
}
if *trace {
log.SetLevel(log.TraceLevel)
log.SetReportCaller(true)
}
}
func main() {
config := config.New()
config.Load()
log.Debugf("main(): config=%+v", config)
repo := repository.New(config.GetRepositoryURL())
defer repo.Close()
log.Debugf("main(): repo=%+v", repo)
syncersConfig := syncer.NewConfig()
syncersConfig.Load()
log.Debugf("main(): config=%+v", syncersConfig)
syncers := syncer.New(syncersConfig)
defer syncers.Close(syncersConfig)
log.Debugf("main(): syncers=%+v", syncers)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err := syncer.Start(ctx, syncers, syncersConfig); err != nil {
log.Fatalf("main(): syncer.Start() error=%w", err)
}
}