package controllers
|
|
import (
|
"basic.com/pubsub/esutil.git"
|
"basic.com/valib/bhomeclient.git"
|
"vamicro/config"
|
"vamicro/system-service/sys"
|
)
|
|
type SyncEsNodeController struct {
|
}
|
|
type HostInfo struct {
|
BinPath string `json:"binPath"`
|
ConfigPath string `json:"configPath"`
|
Hosts []string `json:"hosts"`
|
}
|
|
//同步Hosts
|
func (sen *SyncEsNodeController) SynchronizeHosts(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
|
var hi HostInfo
|
c.BindJSON(&hi)
|
localIp, _, _ := sys.GetLocalIP(config.Server.NetworkAdapter)
|
localPort := "9200"
|
sp := esutil.StopServer(hi.BinPath, localIp, localPort)
|
if sp == false {
|
return &bhomeclient.Reply{Msg: "配置文件错误,本机ip获取失败"}
|
}
|
_, errS := esutil.SetDiscoveryZenPingUnicastHosts(hi.ConfigPath, hi.Hosts)
|
if errS != nil {
|
return &bhomeclient.Reply{Msg: errS.Error()}
|
}
|
st := esutil.StartServer(hi.BinPath, localIp, localPort)
|
if st == false {
|
return &bhomeclient.Reply{Msg: "服务启动超时"}
|
}
|
return &bhomeclient.Reply{Success: true, Msg: "修改成功"}
|
}
|