MCPcopy
hub / github.com/ccfos/nightingale / Initialize

Function Initialize

center/center.go:44–168  ·  view source on GitHub ↗
(configDir string, cryptoKey string)

Source from the content-addressed store, hash-verified

42)
43
44func Initialize(configDir string, cryptoKey string) (func(), error) {
45 config, err := conf.InitConfig(configDir, cryptoKey)
46 if err != nil {
47 return nil, fmt.Errorf("failed to init config: %v", err)
48 }
49
50 cconf.LoadMetricsYaml(configDir, config.Center.MetricsYamlFile)
51 cconf.LoadOpsYaml(configDir, config.Center.OpsYamlFile)
52
53 cconf.MergeOperationConf()
54
55 if config.Alert.Heartbeat.EngineName == "" {
56 config.Alert.Heartbeat.EngineName = "default"
57 }
58
59 logxClean, err := logx.Init(config.Log)
60 if err != nil {
61 return nil, err
62 }
63
64 i18nx.Init(configDir)
65 flashduty.Init(config.Center.FlashDuty)
66
67 db, err := storage.New(config.DB)
68 if err != nil {
69 return nil, err
70 }
71 ctx := ctx.NewContext(context.Background(), db, true)
72 migrate.Migrate(db)
73 isRootInit := models.InitRoot(ctx)
74
75 config.HTTP.JWTAuth.SigningKey = models.InitJWTSigningKey(ctx)
76
77 err = rsa.InitRSAConfig(ctx, &config.HTTP.RSA)
78 if err != nil {
79 return nil, err
80 }
81
82 go integration.Init(ctx, config.Center.BuiltinIntegrationsDir)
83 var redis storage.Redis
84 redis, err = storage.NewRedis(config.Redis)
85 if err != nil {
86 return nil, err
87 }
88
89 metas := metas.New(redis)
90 idents := idents.New(ctx, redis, config.Pushgw)
91
92 syncStats := memsto.NewSyncStats()
93 alertStats := astats.NewSyncStats()
94
95 if config.Center.MigrateBusiGroupLabel || models.CanMigrateBg(ctx) {
96 models.MigrateBg(ctx, config.Pushgw.BusiGroupLabelKey)
97 }
98 if models.CanMigrateEP(ctx) {
99 models.MigrateEP(ctx)
100 }
101

Callers 1

mainFunction · 0.92

Calls 15

InitConfigFunction · 0.92
LoadMetricsYamlFunction · 0.92
LoadOpsYamlFunction · 0.92
MergeOperationConfFunction · 0.92
InitFunction · 0.92
InitFunction · 0.92
InitFunction · 0.92
NewFunction · 0.92
MigrateFunction · 0.92
InitRootFunction · 0.92
InitJWTSigningKeyFunction · 0.92
InitRSAConfigFunction · 0.92

Tested by

no test coverage detected