This commit is contained in:
parent
5f25d955a9
commit
9c701edb86
20
conf/wide.go
20
conf/wide.go
|
@ -18,7 +18,6 @@ package conf
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -267,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, confServer, confChannel string, confDocker bool) {
|
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)
|
||||||
|
@ -331,23 +330,6 @@ func Load(confPath, confIP, confPort, confServer, confChannel string, confDocker
|
||||||
Wide.SessionChannel = confChannel
|
Wide.SessionChannel = confChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
// Docker
|
|
||||||
if confDocker {
|
|
||||||
h, err := net.LookupHost("wide")
|
|
||||||
if nil != err {
|
|
||||||
glog.Error(err)
|
|
||||||
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: secure protocol wss enchance
|
|
||||||
channel := "ws://" + h[0] + ":" + Wide.Port
|
|
||||||
Wide.EditorChannel = channel
|
|
||||||
Wide.OutputChannel = channel
|
|
||||||
Wide.ShellChannel = channel
|
|
||||||
Wide.SessionChannel = channel
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{Port}", Wide.Port, 1)
|
Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{Port}", Wide.Port, 1)
|
||||||
|
|
3
main.go
3
main.go
|
@ -45,7 +45,6 @@ func init() {
|
||||||
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")
|
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
||||||
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
|
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
|
||||||
confDocker := flag.Bool("docker", false, "whether run in a docker container")
|
|
||||||
|
|
||||||
flag.Set("logtostderr", "true")
|
flag.Set("logtostderr", "true")
|
||||||
flag.Set("v", "3")
|
flag.Set("v", "3")
|
||||||
|
@ -55,7 +54,7 @@ func init() {
|
||||||
|
|
||||||
event.Load()
|
event.Load()
|
||||||
|
|
||||||
conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel, *confDocker)
|
conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel)
|
||||||
|
|
||||||
conf.FixedTimeCheckEnv()
|
conf.FixedTimeCheckEnv()
|
||||||
conf.FixedTimeSave()
|
conf.FixedTimeSave()
|
||||||
|
|
Loading…
Reference in New Issue