frostfs-node/cmd/neofs-node/main.go
Alex Vanin 74a68af5c2 [#302] Fix golint underscore linter errors
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-01-12 18:47:02 +03:00

70 lines
987 B
Go

package main
import (
"flag"
"log"
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
)
func fatalOnErr(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
configFile := flag.String("config", "", "path to config")
flag.Parse()
c := initCfg(*configFile)
initApp(c)
bootUp(c)
wait(c)
shutdown(c)
}
func initApp(c *cfg) {
c.ctx = grace.NewGracefulContext(nil)
initGRPC(c)
initNetmapService(c)
initAccountingService(c)
initContainerService(c)
initSessionService(c)
initObjectService(c)
initProfiler(c)
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Open())
fatalOnErr(c.cfgObject.cfgLocalStorage.localStorage.Init())
listenMorphNotifications(c)
}
func bootUp(c *cfg) {
serveProfiler(c)
serveGRPC(c)
bootstrapNode(c)
startWorkers(c)
}
func wait(c *cfg) {
c.log.Info("application started")
<-c.ctx.Done()
}
func shutdown(c *cfg) {
c.cfgGRPC.server.GracefulStop()
c.log.Info("gRPC server stopped")
goOffline(c)
c.wg.Wait()
}