forked from TrueCloudLab/frostfs-node
[#1436] node: Log service initialization/boot up
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
d84d52924a
commit
da3ae202f0
5 changed files with 46 additions and 21 deletions
|
@ -55,7 +55,9 @@ func initControlService(c *cfg) {
|
||||||
control.RegisterControlServiceServer(c.cfgControlService.server, ctlSvc)
|
control.RegisterControlServiceServer(c.cfgControlService.server, ctlSvc)
|
||||||
|
|
||||||
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
||||||
|
runAndLog(c, "control", false, func(c *cfg) {
|
||||||
fatalOnErr(c.cfgControlService.server.Serve(lis))
|
fatalOnErr(c.cfgControlService.server.Serve(lis))
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,32 +66,49 @@ func main() {
|
||||||
shutdown(c)
|
shutdown(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initAndLog(c *cfg, name string, initializer func(*cfg)) {
|
||||||
|
c.log.Info(fmt.Sprintf("initializing %s service...", name))
|
||||||
|
initializer(c)
|
||||||
|
c.log.Info(fmt.Sprintf("%s service has been successfully initialized", name))
|
||||||
|
}
|
||||||
|
|
||||||
func initApp(c *cfg) {
|
func initApp(c *cfg) {
|
||||||
c.ctx, c.ctxCancel = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
c.ctx, c.ctxCancel = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
|
||||||
initGRPC(c)
|
initAndLog(c, "gRPC", initGRPC)
|
||||||
|
initAndLog(c, "netmap", initNetmapService)
|
||||||
initNetmapService(c)
|
initAndLog(c, "accounting", initAccountingService)
|
||||||
initAccountingService(c)
|
initAndLog(c, "container", initContainerService)
|
||||||
initContainerService(c)
|
initAndLog(c, "session", initSessionService)
|
||||||
initSessionService(c)
|
initAndLog(c, "reputation", initReputationService)
|
||||||
initReputationService(c)
|
initAndLog(c, "notification", initNotifications)
|
||||||
initNotifications(c)
|
initAndLog(c, "object", initObjectService)
|
||||||
initObjectService(c)
|
initAndLog(c, "profiler", initProfiler)
|
||||||
initProfiler(c)
|
initAndLog(c, "metrics", initMetrics)
|
||||||
initMetrics(c)
|
initAndLog(c, "control", initControlService)
|
||||||
initControlService(c)
|
|
||||||
|
|
||||||
|
initAndLog(c, "storage engine", func(c *cfg) {
|
||||||
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
|
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
|
||||||
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Init())
|
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Init())
|
||||||
|
})
|
||||||
|
|
||||||
listenMorphNotifications(c)
|
initAndLog(c, "morph notifications", listenMorphNotifications)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAndLog(c *cfg, name string, logSuccess bool, starter func(*cfg)) {
|
||||||
|
c.log.Info(fmt.Sprintf("starting %s service...", name))
|
||||||
|
starter(c)
|
||||||
|
|
||||||
|
if logSuccess {
|
||||||
|
c.log.Info(fmt.Sprintf("%s service started successfully", name))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootUp(c *cfg) {
|
func bootUp(c *cfg) {
|
||||||
connectNats(c)
|
runAndLog(c, "NATS", true, connectNats)
|
||||||
serveGRPC(c)
|
runAndLog(c, "gRPC", false, serveGRPC)
|
||||||
makeAndWaitNotaryDeposit(c)
|
runAndLog(c, "notary", true, makeAndWaitNotaryDeposit)
|
||||||
|
|
||||||
bootstrapNode(c)
|
bootstrapNode(c)
|
||||||
startWorkers(c)
|
startWorkers(c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ func initMetrics(c *cfg) {
|
||||||
)
|
)
|
||||||
|
|
||||||
c.workers = append(c.workers, newWorkerFromFunc(func(context.Context) {
|
c.workers = append(c.workers, newWorkerFromFunc(func(context.Context) {
|
||||||
|
runAndLog(c, "metrics", false, func(c *cfg) {
|
||||||
fatalOnErr(srv.Serve())
|
fatalOnErr(srv.Serve())
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
c.closers = append(c.closers, func() {
|
c.closers = append(c.closers, func() {
|
||||||
|
|
|
@ -207,7 +207,9 @@ func listenMorphNotifications(c *cfg) {
|
||||||
fatalOnErr(err)
|
fatalOnErr(err)
|
||||||
|
|
||||||
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
||||||
|
runAndLog(c, "morph notification", false, func(c *cfg) {
|
||||||
lis.ListenWithError(ctx, c.internalErr)
|
lis.ListenWithError(ctx, c.internalErr)
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
setNetmapNotificationParser(c, newEpochNotification, netmapEvent.ParseNewEpoch)
|
setNetmapNotificationParser(c, newEpochNotification, netmapEvent.ParseNewEpoch)
|
||||||
|
|
|
@ -26,7 +26,9 @@ func initProfiler(c *cfg) {
|
||||||
)
|
)
|
||||||
|
|
||||||
c.workers = append(c.workers, newWorkerFromFunc(func(context.Context) {
|
c.workers = append(c.workers, newWorkerFromFunc(func(context.Context) {
|
||||||
|
runAndLog(c, "profiler", false, func(c *cfg) {
|
||||||
fatalOnErr(srv.Serve())
|
fatalOnErr(srv.Serve())
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
c.closers = append(c.closers, func() {
|
c.closers = append(c.closers, func() {
|
||||||
|
|
Loading…
Reference in a new issue