[#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) {
|
||||||
fatalOnErr(c.cfgControlService.server.Serve(lis))
|
runAndLog(c, "control", false, func(c *cfg) {
|
||||||
|
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)
|
||||||
|
initAndLog(c, "accounting", initAccountingService)
|
||||||
|
initAndLog(c, "container", initContainerService)
|
||||||
|
initAndLog(c, "session", initSessionService)
|
||||||
|
initAndLog(c, "reputation", initReputationService)
|
||||||
|
initAndLog(c, "notification", initNotifications)
|
||||||
|
initAndLog(c, "object", initObjectService)
|
||||||
|
initAndLog(c, "profiler", initProfiler)
|
||||||
|
initAndLog(c, "metrics", initMetrics)
|
||||||
|
initAndLog(c, "control", initControlService)
|
||||||
|
|
||||||
initNetmapService(c)
|
initAndLog(c, "storage engine", func(c *cfg) {
|
||||||
initAccountingService(c)
|
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
|
||||||
initContainerService(c)
|
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Init())
|
||||||
initSessionService(c)
|
})
|
||||||
initReputationService(c)
|
|
||||||
initNotifications(c)
|
|
||||||
initObjectService(c)
|
|
||||||
initProfiler(c)
|
|
||||||
initMetrics(c)
|
|
||||||
initControlService(c)
|
|
||||||
|
|
||||||
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
|
initAndLog(c, "morph notifications", listenMorphNotifications)
|
||||||
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Init())
|
}
|
||||||
|
|
||||||
listenMorphNotifications(c)
|
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) {
|
||||||
fatalOnErr(srv.Serve())
|
runAndLog(c, "metrics", false, func(c *cfg) {
|
||||||
|
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) {
|
||||||
lis.ListenWithError(ctx, c.internalErr)
|
runAndLog(c, "morph notification", false, func(c *cfg) {
|
||||||
|
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) {
|
||||||
fatalOnErr(srv.Serve())
|
runAndLog(c, "profiler", false, func(c *cfg) {
|
||||||
|
fatalOnErr(srv.Serve())
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
c.closers = append(c.closers, func() {
|
c.closers = append(c.closers, func() {
|
||||||
|
|
Loading…
Reference in a new issue