This commit is contained in:
parent
8d0504894a
commit
aeef2afb2e
18
conf/wide.go
18
conf/wide.go
|
@ -266,7 +266,7 @@ func Save() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the configurations from wide.json.
|
// Load loads the configurations from wide.json.
|
||||||
func Load(confPath, confIP, confPort string) {
|
func Load(confPath, confIP, confPort, confServer, confChannel string) {
|
||||||
bytes, _ := ioutil.ReadFile(confPath)
|
bytes, _ := ioutil.ReadFile(confPath)
|
||||||
|
|
||||||
err := json.Unmarshal(bytes, &Wide)
|
err := json.Unmarshal(bytes, &Wide)
|
||||||
|
@ -302,11 +302,27 @@ func Load(confPath, confIP, confPort string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1)
|
Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1)
|
||||||
|
if "" != confServer {
|
||||||
|
Wide.Server = confServer
|
||||||
|
}
|
||||||
|
|
||||||
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", Wide.IP, 1)
|
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", Wide.IP, 1)
|
||||||
Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{IP}", Wide.IP, 1)
|
Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{IP}", Wide.IP, 1)
|
||||||
|
if "" != confChannel {
|
||||||
|
Wide.EditorChannel = confChannel
|
||||||
|
}
|
||||||
Wide.OutputChannel = strings.Replace(Wide.OutputChannel, "{IP}", Wide.IP, 1)
|
Wide.OutputChannel = strings.Replace(Wide.OutputChannel, "{IP}", Wide.IP, 1)
|
||||||
|
if "" != confChannel {
|
||||||
|
Wide.OutputChannel = confChannel
|
||||||
|
}
|
||||||
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", Wide.IP, 1)
|
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", Wide.IP, 1)
|
||||||
|
if "" != confChannel {
|
||||||
|
Wide.ShellChannel = confChannel
|
||||||
|
}
|
||||||
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", Wide.IP, 1)
|
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", Wide.IP, 1)
|
||||||
|
if "" != confChannel {
|
||||||
|
Wide.SessionChannel = confChannel
|
||||||
|
}
|
||||||
|
|
||||||
Wide.Server = strings.Replace(Wide.Server, "{Port}", Wide.Port, 1)
|
Wide.Server = strings.Replace(Wide.Server, "{Port}", Wide.Port, 1)
|
||||||
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{Port}", Wide.Port, 1)
|
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{Port}", Wide.Port, 1)
|
||||||
|
|
4
main.go
4
main.go
|
@ -43,6 +43,8 @@ func init() {
|
||||||
confPath := flag.String("conf", "conf/wide.json", "path of wide.json")
|
confPath := flag.String("conf", "conf/wide.json", "path of wide.json")
|
||||||
confIP := flag.String("ip", "", "ip to visit")
|
confIP := flag.String("ip", "", "ip to visit")
|
||||||
confPort := flag.String("port", "", "port to visit")
|
confPort := flag.String("port", "", "port to visit")
|
||||||
|
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
||||||
|
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
|
||||||
|
|
||||||
flag.Set("logtostderr", "true")
|
flag.Set("logtostderr", "true")
|
||||||
flag.Set("v", "3")
|
flag.Set("v", "3")
|
||||||
|
@ -52,7 +54,7 @@ func init() {
|
||||||
|
|
||||||
event.Load()
|
event.Load()
|
||||||
|
|
||||||
conf.Load(*confPath, *confIP, *confPort)
|
conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel)
|
||||||
|
|
||||||
conf.FixedTimeCheckEnv()
|
conf.FixedTimeCheckEnv()
|
||||||
conf.FixedTimeSave()
|
conf.FixedTimeSave()
|
||||||
|
|
Loading…
Reference in New Issue