forked from TrueCloudLab/frostfs-node
1a169a1a9d
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
59 lines
741 B
Go
59 lines
741 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)
|
|
|
|
init_(c)
|
|
|
|
bootUp(c)
|
|
|
|
wait(c)
|
|
|
|
shutdown(c)
|
|
}
|
|
|
|
func init_(c *cfg) {
|
|
c.ctx = grace.NewGracefulContext(nil)
|
|
|
|
initGRPC(c)
|
|
|
|
initAccountingService(c)
|
|
initContainerService(c)
|
|
initSessionService(c)
|
|
initObjectService(c)
|
|
}
|
|
|
|
func bootUp(c *cfg) {
|
|
serveGRPC(c)
|
|
bootstrapNode(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")
|
|
|
|
c.wg.Wait()
|
|
}
|