frostfs-node/cmd/neofs-node/main.go
Alex Vanin 86b9aefcae [#28] Make storage node configurable
To run storage node at dev-env environment it should have
configurable parameters. To keep `cfg` structures we can
read configuration from env and yml config file with viper
and parse values such as script hashes, fees, keys into
`cfg` structures.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:35 +03:00

57 lines
712 B
Go

package main
import (
"flag"
"fmt"
"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.ctx.Done()
}
func shutdown(c *cfg) {
c.cfgGRPC.server.GracefulStop()
fmt.Println("gRPC server stopped")
c.wg.Wait()
}