2020-07-10 14:17:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-08-24 09:40:32 +00:00
|
|
|
"fmt"
|
2020-08-21 15:01:59 +00:00
|
|
|
"log"
|
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
container "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
|
|
|
object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
|
|
|
|
session "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
|
|
|
|
containerGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc"
|
|
|
|
objectGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
|
|
|
|
sessionGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/session/grpc"
|
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-08-21 15:01:59 +00:00
|
|
|
c := defaultCfg()
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
container.RegisterContainerServiceServer(c.cfgGRPC.server, containerGRPC.New(new(containerSvc)))
|
|
|
|
session.RegisterSessionServiceServer(c.cfgGRPC.server, sessionGRPC.New(new(sessionSvc)))
|
|
|
|
object.RegisterObjectServiceServer(c.cfgGRPC.server, objectGRPC.New(new(objectSvc)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func bootUp(c *cfg) {
|
2020-08-22 11:03:45 +00:00
|
|
|
serveGRPC(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-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()
|
|
|
|
fmt.Println("gRPC server stopped")
|
2020-08-22 11:03:45 +00:00
|
|
|
|
|
|
|
c.wg.Wait()
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|