containerize

This commit is contained in:
Liang Ding 2014-11-18 14:48:18 +08:00
parent aeef2afb2e
commit 8b1ffe0544
2 changed files with 16 additions and 2 deletions

View File

@ -18,6 +18,7 @@ package conf
import (
"encoding/json"
"io/ioutil"
"net"
"os"
"os/exec"
"path/filepath"
@ -266,7 +267,7 @@ func Save() bool {
}
// Load loads the configurations from wide.json.
func Load(confPath, confIP, confPort, confServer, confChannel string) {
func Load(confPath, confIP, confPort, confServer, confChannel string, confDocker bool) {
bytes, _ := ioutil.ReadFile(confPath)
err := json.Unmarshal(bytes, &Wide)
@ -291,6 +292,18 @@ func Load(confPath, confIP, confPort, confServer, confChannel string) {
glog.V(5).Infof("${ip} [%s]", ip)
if confDocker {
h, err := net.LookupHost("wide")
if nil != err {
glog.Error(err)
os.Exit(-1)
}
ip = h[0]
}
if "" != confIP {
ip = confIP
}

View File

@ -45,6 +45,7 @@ func init() {
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")
confDocker := flag.Bool("docker", false, "whether run in a docker container")
flag.Set("logtostderr", "true")
flag.Set("v", "3")
@ -54,7 +55,7 @@ func init() {
event.Load()
conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel)
conf.Load(*confPath, *confIP, *confPort, *confServer, *confChannel, *confDocker)
conf.FixedTimeCheckEnv()
conf.FixedTimeSave()