file-store/cmd/ssrv.go

39 lines
811 B
Go

package cmd
import (
// "path/filepath"
// "fmt"
"net"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"git.keganmyers.com/terribleplan/file-store/pkg/storeserver"
)
var (
scmd_Listen string
)
func init() {
ssrv.Flags().StringVar(&scmd_Listen, "listen", "127.0.0.1:9182", "The address on which to listen for connections (default: 127.0.0.1:9182)")
root.AddCommand(ssrv)
}
var ssrv = &cobra.Command{
Use: "ssrv [storage-dir]",
Short: "Run a store server",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
sock, err := net.Listen("tcp", scmd_Listen)
if err != nil {
panic(err)
}
var opts []grpc.ServerOption
// ...
grpcServer := grpc.NewServer(opts...)
storeserver.NewProto(storeserver.NewLocal(args[0]), grpcServer)
grpcServer.Serve(sock)
},
}