tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2019-11-01 5f9516b33f1d030ce160da709997bdb746b1d57f
set config
4个文件已修改
43 ■■■■■ 已修改文件
.gitignore 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
esutil/EsClient.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
extend/config/config.go 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -0,0 +1,2 @@
.idea
test.exe
esutil/EsClient.go
@@ -12,7 +12,7 @@
    "strings"
    "sync"
    "time"
    "andriodServer/config"
    "andriodServer/extend/config"
    log "andriodServer/log"
)
extend/config/config.go
@@ -1 +1,38 @@
package config
import (
    "log"
    "strconv"
    "github.com/spf13/viper"
)
type server []ServerInfo
type ServerInfo struct {
    ServerId string `mapstructure: "serverId"`
    ServerIp string `mapstructure: "serverIp"`
    VideoPort int   `mapstructure: "videoPort"`
    NginxIp string  `mapstructure: "ngxIp"`
    NginxPort int   `mapstructure: "ngxPort"`
}
var serverList = &server{}
var ServerMap = make(map[string]string,0)
var NgxMap = make(map[string]string,0)
func Init(env string) {
    var err error
    viper.SetConfigType("yaml")
    viper.SetConfigName(env)
    viper.AddConfigPath("./config/")
    err = viper.ReadInConfig()
    if err != nil {
        log.Fatal("error on parsing configuration file")
    }
    viper.UnmarshalKey("server", serverList)
    for _,s :=range *serverList {
        ServerMap[s.ServerId] = "http://"+s.ServerIp+":"+strconv.Itoa(s.VideoPort)+"/getRecordVideoPath"
        NgxMap[s.ServerId] = "http://"+s.NginxIp+":"+strconv.Itoa(s.NginxPort)+"/videosource"
    }
}
server.go
@@ -8,7 +8,7 @@
    "time"
    "andriodServer/esutil"
    "andriodServer/config"
    "andriodServer/extend/config"
    log "andriodServer/log"
)