2020-07-10 17:17:51 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-08-24 12:40:32 +03:00
|
|
|
"fmt"
|
2020-08-21 18:01:59 +03:00
|
|
|
"log"
|
|
|
|
|
2020-08-21 14:32:03 +03:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
2020-07-10 17:17:51 +03:00
|
|
|
)
|
|
|
|
|
2020-08-21 18:01:59 +03:00
|
|
|
func fatalOnErr(err error) {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-10 17:17:51 +03:00
|
|
|
func main() {
|
2020-08-21 18:01:59 +03:00
|
|
|
c := defaultCfg()
|
|
|
|
|
2020-08-24 12:40:32 +03:00
|
|
|
init_(c)
|
|
|
|
|
|
|
|
bootUp(c)
|
|
|
|
|
|
|
|
wait(c)
|
|
|
|
|
|
|
|
shutdown(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init_(c *cfg) {
|
2020-08-22 14:03:45 +03:00
|
|
|
c.ctx = grace.NewGracefulContext(nil)
|
2020-08-21 18:01:59 +03:00
|
|
|
|
2020-08-24 12:40:32 +03:00
|
|
|
initGRPC(c)
|
|
|
|
|
|
|
|
initAccountingService(c)
|
2020-08-24 17:07:08 +03:00
|
|
|
initContainerService(c)
|
2020-08-24 18:51:42 +03:00
|
|
|
initSessionService(c)
|
2020-08-25 16:37:10 +03:00
|
|
|
initObjectService(c)
|
2020-08-24 12:40:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func bootUp(c *cfg) {
|
2020-08-22 14:03:45 +03:00
|
|
|
serveGRPC(c)
|
2020-08-24 12:40:32 +03:00
|
|
|
}
|
2020-07-10 17:17:51 +03:00
|
|
|
|
2020-08-24 12:40:32 +03:00
|
|
|
func wait(c *cfg) {
|
2020-08-22 14:03:45 +03:00
|
|
|
<-c.ctx.Done()
|
2020-08-24 12:40:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func shutdown(c *cfg) {
|
|
|
|
c.cfgGRPC.server.GracefulStop()
|
|
|
|
fmt.Println("gRPC server stopped")
|
2020-08-22 14:03:45 +03:00
|
|
|
|
|
|
|
c.wg.Wait()
|
2020-07-10 17:17:51 +03:00
|
|
|
}
|