From c9d5fbfe64e330d6c0293f175c126d2c4bc07912 Mon Sep 17 00:00:00 2001 From: Kyaw Myint Thein Date: Sun, 21 Aug 2016 10:55:10 +0800 Subject: [PATCH 1/2] add runmode flag on bee run to set BEEGO_RUNMODE env --- run.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/run.go b/run.go index b2f94da..8aab6b5 100644 --- a/run.go +++ b/run.go @@ -24,7 +24,7 @@ import ( ) var cmdRun = &Command{ - UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-vendor=true] [-e=folderToExclude] [-tags=goBuildTags]", + UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-vendor=true] [-e=folderToExclude] [-tags=goBuildTags] [-runmode=BEEGO_RUNMODE]", Short: "run the app and start a Web server for development", Long: ` Run command will supervise the file system of the beego project using inotify, @@ -51,6 +51,8 @@ var ( vendorWatch bool // Current user workspace currentGoPath string + // Current runmode + runmode string ) func init() { @@ -61,6 +63,7 @@ func init() { cmdRun.Flag.Var(&excludedPaths, "e", "Excluded paths[].") cmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Watch vendor folder") cmdRun.Flag.StringVar(&buildTags, "tags", "", "Build tags (https://golang.org/pkg/go/build/)") + cmdRun.Flag.StringVar(&runmode, "runmode", "", "Set BEEGO_RUNMODE env variable.") exit = make(chan bool) } @@ -100,6 +103,16 @@ func runApp(cmd *Command, args []string) int { Debugf("current path:%s\n", currpath) + if runmode == "prod" || runmode == "dev"{ + os.Setenv("BEEGO_RUNMODE", runmode) + ColorLog("[INFO] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) + }else if runmode != ""{ + os.Setenv("BEEGO_RUNMODE", runmode) + ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) + }else if os.Getenv("BEEGO_RUNMODE") != ""{ + ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) + } + err := loadConfig() if err != nil { ColorLog("[ERRO] Fail to parse bee.json[ %s ]\n", err) From 368b69b73f82763c386ab9314f7b7d1c089b3939 Mon Sep 17 00:00:00 2001 From: Kyaw Myint Thein Date: Sun, 21 Aug 2016 10:56:28 +0800 Subject: [PATCH 2/2] update readme file for bee run --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fecb3e9..e9a60e1 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,7 @@ For instance, to get more information about the `run` command: ```bash $ bee help run -usage: bee run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] +usage: bee run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-runmode=BEEGO_RUNMODE] start the appname throw exec.Command