cmd args ip and port
This commit is contained in:
parent
56fc7de68a
commit
1a1a09edfe
34
conf/wide.go
34
conf/wide.go
|
@ -71,12 +71,13 @@ type Editor struct {
|
||||||
// Configuration.
|
// Configuration.
|
||||||
type conf struct {
|
type conf struct {
|
||||||
IP string // server ip, ${ip}
|
IP string // server ip, ${ip}
|
||||||
Server string // server host and port ({IP}:7070)
|
Port string // server port
|
||||||
StaticServer string // static resources server scheme, host and port (http://{IP}:7070)
|
Server string // server host and port ({IP}:{Port})
|
||||||
EditorChannel string // editor channel (ws://{IP}:7070)
|
StaticServer string // static resources server scheme, host and port (http://{IP}:{Port})
|
||||||
OutputChannel string // output channel (ws://{IP}:7070)
|
EditorChannel string // editor channel (ws://{IP}:{Port})
|
||||||
ShellChannel string // shell channel(ws://{IP}:7070)
|
OutputChannel string // output channel (ws://{IP}:{Port})
|
||||||
SessionChannel string // wide session channel (ws://{IP}:7070)
|
ShellChannel string // shell channel(ws://{IP}:{Port})
|
||||||
|
SessionChannel string // wide session channel (ws://{IP}:{Port})
|
||||||
HTTPSessionMaxAge int // HTTP session max age (in seciond)
|
HTTPSessionMaxAge int // HTTP session max age (in seciond)
|
||||||
StaticResourceVersion string // version of static resources
|
StaticResourceVersion string // version of static resources
|
||||||
MaxProcs int // Go max procs
|
MaxProcs int // Go max procs
|
||||||
|
@ -265,7 +266,7 @@ func Save() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the configurations from wide.json.
|
// Load loads the configurations from wide.json.
|
||||||
func Load(confPath string) {
|
func Load(confPath, confIP, confPort string) {
|
||||||
bytes, _ := ioutil.ReadFile(confPath)
|
bytes, _ := ioutil.ReadFile(confPath)
|
||||||
|
|
||||||
err := json.Unmarshal(bytes, &Wide)
|
err := json.Unmarshal(bytes, &Wide)
|
||||||
|
@ -278,6 +279,9 @@ func Load(confPath string) {
|
||||||
// keep the raw content
|
// keep the raw content
|
||||||
json.Unmarshal(bytes, &rawWide)
|
json.Unmarshal(bytes, &rawWide)
|
||||||
|
|
||||||
|
Wide.WD = util.OS.Pwd()
|
||||||
|
glog.V(5).Infof("${pwd} [%s]", Wide.WD)
|
||||||
|
|
||||||
ip, err := util.Net.LocalIP()
|
ip, err := util.Net.LocalIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Error(err)
|
glog.Error(err)
|
||||||
|
@ -287,11 +291,16 @@ func Load(confPath string) {
|
||||||
|
|
||||||
glog.V(5).Infof("${ip} [%s]", ip)
|
glog.V(5).Infof("${ip} [%s]", ip)
|
||||||
|
|
||||||
Wide.WD = util.OS.Pwd()
|
if "" != confIP {
|
||||||
glog.V(5).Infof("${pwd} [%s]", Wide.WD)
|
ip = confIP
|
||||||
|
}
|
||||||
|
|
||||||
Wide.IP = strings.Replace(Wide.IP, "${ip}", ip, 1)
|
Wide.IP = strings.Replace(Wide.IP, "${ip}", ip, 1)
|
||||||
|
|
||||||
|
if "" != confPort {
|
||||||
|
Wide.Port = confPort
|
||||||
|
}
|
||||||
|
|
||||||
Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1)
|
Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1)
|
||||||
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)
|
||||||
|
@ -299,6 +308,13 @@ func Load(confPath string) {
|
||||||
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", Wide.IP, 1)
|
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", Wide.IP, 1)
|
||||||
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", Wide.IP, 1)
|
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", Wide.IP, 1)
|
||||||
|
|
||||||
|
Wide.Server = strings.Replace(Wide.Server, "{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.OutputChannel = strings.Replace(Wide.OutputChannel, "{Port}", Wide.Port, 1)
|
||||||
|
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{Port}", Wide.Port, 1)
|
||||||
|
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{Port}", Wide.Port, 1)
|
||||||
|
|
||||||
glog.V(5).Info("Conf: \n" + string(bytes))
|
glog.V(5).Info("Conf: \n" + string(bytes))
|
||||||
|
|
||||||
initWorkspaceDirs()
|
initWorkspaceDirs()
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
"IP": "${ip}",
|
"IP": "${ip}",
|
||||||
"Server": "{IP}:7070",
|
"Port": "7070",
|
||||||
|
"Server": "{IP}:{Port}",
|
||||||
"StaticServer": "",
|
"StaticServer": "",
|
||||||
"EditorChannel": "ws://{IP}:7070",
|
"EditorChannel": "ws://{IP}:{Port}",
|
||||||
"OutputChannel": "ws://{IP}:7070",
|
"OutputChannel": "ws://{IP}:{Port}",
|
||||||
"ShellChannel": "ws://{IP}:7070",
|
"ShellChannel": "ws://{IP}:{Port}",
|
||||||
"SessionChannel": "ws://{IP}:7070",
|
"SessionChannel": "ws://{IP}:{Port}",
|
||||||
"HTTPSessionMaxAge": 86400,
|
"HTTPSessionMaxAge": 86400,
|
||||||
"StaticResourceVersion": "201411171800",
|
"StaticResourceVersion": "201411171800",
|
||||||
"MaxProcs": 4,
|
"MaxProcs": 4,
|
||||||
|
@ -27,20 +28,9 @@
|
||||||
"LineHeight": "17px"
|
"LineHeight": "17px"
|
||||||
},
|
},
|
||||||
"LatestSessionContent": {
|
"LatestSessionContent": {
|
||||||
"FileTree": [
|
"FileTree": [],
|
||||||
"E:\\Work\\go\\src",
|
"Files": [],
|
||||||
"E:\\Work\\go\\src\\code.google.com\\p",
|
"CurrentFile": ""
|
||||||
"E:\\Work\\go\\src\\code.google.com\\p\\go.net",
|
|
||||||
"E:\\Work\\go\\src\\github.com",
|
|
||||||
"E:\\Work\\go\\src\\github.com\\88250",
|
|
||||||
"E:\\Work\\go\\src\\github.com\\88250\\gohtml"
|
|
||||||
],
|
|
||||||
"Files": [
|
|
||||||
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\consts.go",
|
|
||||||
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\doc.go",
|
|
||||||
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\formatter.go"
|
|
||||||
],
|
|
||||||
"CurrentFile": "E:\\Work\\go\\src\\github.com\\88250\\gohtml\\formatter.go"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
4
main.go
4
main.go
|
@ -41,6 +41,8 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
// TODO: args
|
// TODO: args
|
||||||
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")
|
||||||
|
confPort := flag.String("port", "", "port to visit")
|
||||||
|
|
||||||
flag.Set("logtostderr", "true")
|
flag.Set("logtostderr", "true")
|
||||||
flag.Set("v", "3")
|
flag.Set("v", "3")
|
||||||
|
@ -50,7 +52,7 @@ func init() {
|
||||||
|
|
||||||
event.Load()
|
event.Load()
|
||||||
|
|
||||||
conf.Load(*confPath)
|
conf.Load(*confPath, *confIP, *confPort)
|
||||||
|
|
||||||
conf.FixedTimeCheckEnv()
|
conf.FixedTimeCheckEnv()
|
||||||
conf.FixedTimeSave()
|
conf.FixedTimeSave()
|
||||||
|
|
Loading…
Reference in New Issue