forked from TrueCloudLab/frostfs-node
86b9aefcae
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>
30 lines
459 B
Go
30 lines
459 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func initGRPC(c *cfg) {
|
|
var err error
|
|
|
|
c.cfgGRPC.listener, err = net.Listen("tcp", c.viper.GetString(cfgListenAddress))
|
|
fatalOnErr(err)
|
|
|
|
c.cfgGRPC.server = grpc.NewServer()
|
|
}
|
|
|
|
func serveGRPC(c *cfg) {
|
|
go func() {
|
|
c.wg.Add(1)
|
|
defer func() {
|
|
c.wg.Done()
|
|
}()
|
|
|
|
if err := c.cfgGRPC.server.Serve(c.cfgGRPC.listener); err != nil {
|
|
fmt.Println("gRPC server error", err)
|
|
}
|
|
}()
|
|
}
|