1
0
mirror of https://github.com/beego/bee.git synced 2024-11-24 13:30:53 +00:00
bee/start.go

54 lines
968 B
Go
Raw Normal View History

2012-12-15 16:56:28 +00:00
package main
import (
"fmt"
"os"
"path"
)
var cmdStart = &Command{
UsageLine: "start [appname]",
Short: "start the app which can hot compile",
Long: `
start the appname throw exec.Command
then start a inotify watch for current dir
when the file has changed bee will auto go build and restart the app
file changed
|
checked is go file
|
yes no
| |
go build do nothing
|
restart app
`,
}
func init() {
cmdStart.Run = startapp
}
func startapp(cmd *Command, args []string) {
if len(args) != 1 {
fmt.Println("error args")
os.Exit(2)
}
crupath, _ := os.Getwd()
var paths []string
paths = append(paths, path.Join(crupath, "controllers"), path.Join(crupath, "models"))
NewWatcher(paths)
go Start(args[0])
for {
select {
case <-restart:
go Start(args[0])
case <-builderror:
fmt.Println("build error:", builderror)
}
}
}