2020-07-10 14:17:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-16 07:45:08 +00:00
|
|
|
"flag"
|
2020-08-21 15:01:59 +00:00
|
|
|
"log"
|
|
|
|
|
2020-08-21 11:32:03 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
2020-07-10 14:17:51 +00:00
|
|
|
)
|
|
|
|
|
2020-08-21 15:01:59 +00:00
|
|
|
func fatalOnErr(err error) {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-10 14:17:51 +00:00
|
|
|
func main() {
|
2020-09-16 07:45:08 +00:00
|
|
|
configFile := flag.String("config", "", "path to config")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
c := initCfg(*configFile)
|
2020-08-21 15:01:59 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
init_(c)
|
|
|
|
|
|
|
|
bootUp(c)
|
|
|
|
|
|
|
|
wait(c)
|
|
|
|
|
|
|
|
shutdown(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init_(c *cfg) {
|
2020-08-22 11:03:45 +00:00
|
|
|
c.ctx = grace.NewGracefulContext(nil)
|
2020-08-21 15:01:59 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
initGRPC(c)
|
|
|
|
|
|
|
|
initAccountingService(c)
|
2020-08-24 14:07:08 +00:00
|
|
|
initContainerService(c)
|
2020-08-24 15:51:42 +00:00
|
|
|
initSessionService(c)
|
2020-08-25 13:37:10 +00:00
|
|
|
initObjectService(c)
|
2020-10-02 13:18:38 +00:00
|
|
|
initProfiler(c)
|
2020-08-24 09:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func bootUp(c *cfg) {
|
2020-10-02 13:18:38 +00:00
|
|
|
serveProfiler(c)
|
2020-08-22 11:03:45 +00:00
|
|
|
serveGRPC(c)
|
2020-08-31 15:20:02 +00:00
|
|
|
bootstrapNode(c)
|
2020-08-24 09:40:32 +00:00
|
|
|
}
|
2020-07-10 14:17:51 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
func wait(c *cfg) {
|
2020-09-25 12:34:17 +00:00
|
|
|
c.log.Info("application started")
|
|
|
|
|
2020-08-22 11:03:45 +00:00
|
|
|
<-c.ctx.Done()
|
2020-08-24 09:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func shutdown(c *cfg) {
|
|
|
|
c.cfgGRPC.server.GracefulStop()
|
2020-09-25 12:34:17 +00:00
|
|
|
|
|
|
|
c.log.Info("gRPC server stopped")
|
2020-08-22 11:03:45 +00:00
|
|
|
|
|
|
|
c.wg.Wait()
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|