forked from p93542168/wheat-cache
feat(storage): add conf addr
This commit is contained in:
parent
6b80b30f31
commit
aadb43cfd9
|
@ -9,9 +9,11 @@ import (
|
|||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
_ "gitee.com/timedb/wheatCache/conf"
|
||||
"gitee.com/timedb/wheatCache/storage/proto"
|
||||
"gitee.com/timedb/wheatCache/storage/server"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
@ -24,7 +26,16 @@ var rootCmd = &cobra.Command{
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
storageServer := server.NewServer()
|
||||
// 先写死, 等配置文件
|
||||
listen, err := net.Listen("tcp", ":5201")
|
||||
conf := viper.GetStringMap("storage")
|
||||
host := conf["host"].(string)
|
||||
port := conf["port"].(int)
|
||||
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", host, port))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
listen, err := net.ListenTCP("tcp", tcpAddr)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue