diff --git a/main.go b/main.go index 36c8575..7e9252f 100644 --- a/main.go +++ b/main.go @@ -332,34 +332,14 @@ func startTower() { app = NewApp(c.Conf.App.MainFile, c.Conf.App.Port, c.Conf.App.BuildDir, c.Conf.App.PortParamName) } app.OfflineMode = c.Conf.Offline - app.DisabledLogRequest = c.Conf.LogRequest == false + app.DisabledLogRequest = !c.Conf.LogRequest app.PkgMirrors = c.Conf.App.PkgMirrors app.Env = append(app.Env, c.Conf.App.Env...) if len(c.Conf.App.RunParams) > 0 { - delim := ` ` - param := c.Conf.App.RunParams - //:<分割符>:<参数> - if param[0] == ':' { - param = strings.TrimPrefix(param, `:`) - if pos := strings.Index(param, `:`); pos > 0 { - delim = param[0:pos] - param = param[pos+1:] - } - } - app.RunParams = strings.Split(param, delim) + app.RunParams = parseParams(c.Conf.App.RunParams) } if len(c.Conf.App.BuildParams) > 0 { - delim := ` ` - param := c.Conf.App.BuildParams - //:<分割符>:<参数> - if param[0] == ':' { - param = strings.TrimPrefix(param, `:`) - if pos := strings.Index(param, `:`); pos > 0 { - delim = param[0:pos] - param = param[pos+1:] - } - } - app.BuildParams = strings.Split(param, delim) + app.BuildParams = parseParams(c.Conf.App.BuildParams) } watchedDir := app.Root if !allowBuild { diff --git a/utils.go b/utils.go index 59b75e0..9b15522 100644 --- a/utils.go +++ b/utils.go @@ -6,7 +6,10 @@ import ( "net" "os" "path/filepath" + "strings" "time" + + "github.com/webx-top/com" ) var ( @@ -103,3 +106,18 @@ func quickSort(arr []int64, start, end int) { } } } + +func parseParams(param string) []string { + if param[0] != ':' { + return com.ParseArgs(param) + } + + //:<分割符>:<参数> + delim := ` ` + param = strings.TrimPrefix(param, `:`) + if pos := strings.Index(param, `:`); pos > 0 { + delim = param[0:pos] + param = param[pos+1:] + } + return strings.Split(param, delim) +}