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