-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (49 loc) · 1.12 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
package main
import (
"context"
"errors"
"ipdb/bootstrap"
"ipdb/modules/config"
"log"
"github.com/spf13/viper"
"go.uber.org/fx"
)
type invokeDeps struct {
fx.In
Rest *bootstrap.Serve
}
func main() {
viper.SetConfigType("yaml")
viper.SetConfigName("config.yaml")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
panic("config.yaml file not found")
}
}
err := viper.Unmarshal(&config.GlobalConfig)
if err != nil {
log.Fatalf("unable to decode into struct, %v", err)
}
log.Println(config.GlobalConfig.IPIP.Path)
log.Println(config.GlobalConfig.IP2Location.Path)
// telemetrymod.FxOptions(),
// sensitivemod.FxOptions(),
app := fx.New(
bootstrap.FxOptions(),
fx.Invoke(func(lc fx.Lifecycle, deps invokeDeps) {
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
go deps.Rest.Start()
log.Println("Press Ctrl+C to exit")
return nil
},
OnStop: func(ctx context.Context) error {
//deps.LokiWriter.Shutdown()
return errors.Join(deps.Rest.Stop())
},
})
}),
)
app.Run()
}