🔧 用户元数据目录配置化
This commit is contained in:
parent
1a4feddf34
commit
1d84db7740
10
conf/wide.go
10
conf/wide.go
|
@ -87,9 +87,9 @@ var Users []*User
|
||||||
var Docker bool
|
var Docker bool
|
||||||
|
|
||||||
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
|
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
|
||||||
func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground string, confUsersWorkspaces string) {
|
func Load(confPath, confUsers, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground string, confUsersWorkspaces string) {
|
||||||
initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground, confUsersWorkspaces)
|
initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground, confUsersWorkspaces)
|
||||||
initUsers()
|
initUsers(confUsers)
|
||||||
|
|
||||||
cmd := exec.Command("docker", "version")
|
cmd := exec.Command("docker", "version")
|
||||||
_, err := cmd.CombinedOutput()
|
_, err := cmd.CombinedOutput()
|
||||||
|
@ -98,8 +98,8 @@ func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initUsers() {
|
func initUsers(confUsers string) {
|
||||||
f, err := os.Open("conf/users")
|
f, err := os.Open(confUsers)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ func FixedTimeCheckEnv() {
|
||||||
checkEnv() // check immediately
|
checkEnv() // check immediately
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for _ = range time.Tick(time.Minute * 7) {
|
for _ = range time.Tick(time.Minute*7) {
|
||||||
checkEnv()
|
checkEnv()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
18
main.go
18
main.go
|
@ -49,6 +49,7 @@ var logger *log.Logger
|
||||||
// The only one init function in Wide.
|
// The only one init function in Wide.
|
||||||
func init() {
|
func init() {
|
||||||
confPath := flag.String("conf", "conf/wide.json", "path of wide.json")
|
confPath := flag.String("conf", "conf/wide.json", "path of wide.json")
|
||||||
|
confUsers := flag.String("users", "conf/users", "path of users")
|
||||||
confIP := flag.String("ip", "", "this will overwrite Wide.IP if specified")
|
confIP := flag.String("ip", "", "this will overwrite Wide.IP if specified")
|
||||||
confPort := flag.String("port", "", "this will overwrite Wide.Port if specified")
|
confPort := flag.String("port", "", "this will overwrite Wide.Port if specified")
|
||||||
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
|
||||||
|
@ -65,16 +66,16 @@ func init() {
|
||||||
log.SetLevel("warn")
|
log.SetLevel("warn")
|
||||||
logger = log.NewLogger(os.Stdout)
|
logger = log.NewLogger(os.Stdout)
|
||||||
|
|
||||||
wd := util.OS.Pwd()
|
//wd := util.OS.Pwd()
|
||||||
if strings.HasPrefix(wd, os.TempDir()) {
|
//if strings.HasPrefix(wd, os.TempDir()) {
|
||||||
logger.Error("Don't run Wide in OS' temp directory or with `go run`")
|
// logger.Error("Don't run Wide in OS' temp directory or with `go run`")
|
||||||
|
//
|
||||||
os.Exit(-1)
|
// os.Exit(-1)
|
||||||
}
|
//}
|
||||||
|
|
||||||
i18n.Load()
|
i18n.Load()
|
||||||
event.Load()
|
event.Load()
|
||||||
conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, *confPlayground, *confUsersWorkspaces)
|
conf.Load(*confPath, *confUsers, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, *confPlayground, *confUsersWorkspaces)
|
||||||
|
|
||||||
conf.FixedTimeCheckEnv()
|
conf.FixedTimeCheckEnv()
|
||||||
session.FixedTimeSave()
|
session.FixedTimeSave()
|
||||||
|
@ -84,8 +85,7 @@ func init() {
|
||||||
session.FixedTimeReport()
|
session.FixedTimeReport()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("host ["+runtime.Version()+", "+runtime.GOOS+"_"+runtime.GOARCH+"], cross-compilation ",
|
logger.Debug("host ["+runtime.Version()+", "+runtime.GOOS+"_"+runtime.GOARCH+"], cross-compilation ", util.Go.GetCrossPlatforms())
|
||||||
util.Go.GetCrossPlatforms())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main.
|
// Main.
|
||||||
|
|
Loading…
Reference in New Issue