mirror of
https://github.com/beego/bee.git
synced 2025-07-07 11:30:19 +00:00
Merge branch 'master' of https://github.com/beego/bee
# Conflicts: # generate/swaggergen/g_docs.go
This commit is contained in:
@ -58,6 +58,8 @@ var (
|
||||
currentGoPath string
|
||||
// Current runmode
|
||||
runmode string
|
||||
// Extra args to run application
|
||||
runargs string
|
||||
// Extra directories
|
||||
extraPackages utils.StrFlags
|
||||
)
|
||||
@ -71,6 +73,7 @@ func init() {
|
||||
CmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Enable watch vendor folder.")
|
||||
CmdRun.Flag.StringVar(&buildTags, "tags", "", "Set the build tags. See: https://golang.org/pkg/go/build/")
|
||||
CmdRun.Flag.StringVar(&runmode, "runmode", "", "Set the Beego run mode.")
|
||||
CmdRun.Flag.StringVar(&runargs, "runargs", "", "Extra args to run application")
|
||||
CmdRun.Flag.Var(&extraPackages, "ex", "List of extra package to watch.")
|
||||
exit = make(chan bool)
|
||||
commands.AvailableCommands = append(commands.AvailableCommands, CmdRun)
|
||||
|
@ -36,13 +36,14 @@ var (
|
||||
state sync.Mutex
|
||||
eventTime = make(map[string]int64)
|
||||
scheduleTime time.Time
|
||||
watchExts = []string{".go"}
|
||||
watchExtsStatic = []string{".html", ".tpl", ".js", ".css"}
|
||||
watchExts = config.Conf.WatchExts
|
||||
watchExtsStatic = config.Conf.WatchExtsStatic
|
||||
ignoredFilesRegExps = []string{
|
||||
`.#(\w+).go`,
|
||||
`.(\w+).go.swp`,
|
||||
`(\w+).go~`,
|
||||
`(\w+).tmp`,
|
||||
`commentsRouter_controllers.go`,
|
||||
}
|
||||
)
|
||||
|
||||
@ -86,6 +87,12 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
|
||||
scheduleTime = time.Now().Add(1 * time.Second)
|
||||
time.Sleep(scheduleTime.Sub(time.Now()))
|
||||
AutoBuild(files, isgenerate)
|
||||
|
||||
if config.Conf.EnableReload {
|
||||
// Wait 100ms more before refreshing the browser
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
sendReload(e.String())
|
||||
}
|
||||
}()
|
||||
}
|
||||
case err := <-watcher.Errors:
|
||||
@ -141,9 +148,9 @@ func AutoBuild(files []string, isgenerate bool) {
|
||||
}
|
||||
beeLogger.Log.Success("Docs generated!")
|
||||
}
|
||||
|
||||
appName := appname
|
||||
if err == nil {
|
||||
appName := appname
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
appName += ".exe"
|
||||
}
|
||||
@ -167,7 +174,7 @@ func AutoBuild(files []string, isgenerate bool) {
|
||||
}
|
||||
|
||||
beeLogger.Log.Success("Built Successfully!")
|
||||
Restart(appname)
|
||||
Restart(appName)
|
||||
}
|
||||
|
||||
// Kill kills the running command process
|
||||
@ -202,7 +209,13 @@ func Start(appname string) {
|
||||
cmd = exec.Command(appname)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Args = append([]string{appname}, config.Conf.CmdArgs...)
|
||||
if runargs != "" {
|
||||
r := regexp.MustCompile("'.+'|\".+\"|\\S+")
|
||||
m := r.FindAllString(runargs, -1)
|
||||
cmd.Args = append([]string{appname}, m...)
|
||||
} else {
|
||||
cmd.Args = append([]string{appname}, config.Conf.CmdArgs...)
|
||||
}
|
||||
cmd.Env = append(os.Environ(), config.Conf.Envs...)
|
||||
|
||||
go cmd.Run()
|
||||
|
Reference in New Issue
Block a user