1
0
mirror of https://github.com/beego/bee.git synced 2024-11-24 23:30:55 +00:00

Merge branch 'develop' of https://github.com/beego/bee into develop

This commit is contained in:
LiuYang 2019-01-15 11:57:55 +08:00
commit 9f600ccb45
7 changed files with 27 additions and 14 deletions

View File

@ -35,7 +35,7 @@ var CmdApiapp = &commands.Command{
The command 'api' creates a Beego API application. The command 'api' creates a Beego API application.
{{"Example:"|bold}} {{"Example:"|bold}}
$ bee api [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test] $ bee api [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
If 'conn' argument is empty, the command will generate an example API application. Otherwise the command If 'conn' argument is empty, the command will generate an example API application. Otherwise the command
will connect to your database and generate models based on the existing tables. will connect to your database and generate models based on the existing tables.
@ -511,7 +511,7 @@ import (
) )
func init() { func init() {
_, file, _, _ := runtime.Caller(1) _, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator)))) apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(apppath) beego.TestBeegoInit(apppath)
} }

View File

@ -227,7 +227,7 @@ func startWatcher(paths []string, ch chan int) {
// Wait 1s before re-build until there is no file change // Wait 1s before re-build until there is no file change
scheduleTime := time.Now().Add(1 * time.Second) scheduleTime := time.Now().Add(1 * time.Second)
time.Sleep(scheduleTime.Sub(time.Now())) time.Sleep(time.Until(scheduleTime))
_, err := buildDebug() _, err := buildDebug()
if err != nil { if err != nil {
utils.Notify("Build Failed: "+err.Error(), "bee") utils.Notify("Build Failed: "+err.Error(), "bee")

View File

@ -24,7 +24,7 @@ var CmdHproseapp = &commands.Command{
{{"To scaffold out your application, use:"|bold}} {{"To scaffold out your application, use:"|bold}}
$ bee hprose [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test] $ bee hprose [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
If 'conn' is empty, the command will generate a sample application. Otherwise the command If 'conn' is empty, the command will generate a sample application. Otherwise the command
will connect to your database and generate models based on the existing tables. will connect to your database and generate models based on the existing tables.

View File

@ -101,7 +101,7 @@ import (
) )
func init() { func init() {
_, file, _, _ := runtime.Caller(1) _, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator)))) apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(apppath) beego.TestBeegoInit(apppath)
} }

View File

@ -85,7 +85,7 @@ func NewWatcher(paths []string, files []string, isgenerate bool) {
go func() { go func() {
// Wait 1s before autobuild until there is no file change. // Wait 1s before autobuild until there is no file change.
scheduleTime = time.Now().Add(1 * time.Second) scheduleTime = time.Now().Add(1 * time.Second)
time.Sleep(scheduleTime.Sub(time.Now())) time.Sleep(time.Until(scheduleTime))
AutoBuild(files, isgenerate) AutoBuild(files, isgenerate)
if config.Conf.EnableReload { if config.Conf.EnableReload {
@ -183,10 +183,23 @@ func Kill() {
} }
}() }()
if cmd != nil && cmd.Process != nil { if cmd != nil && cmd.Process != nil {
cmd.Process.Signal(os.Interrupt)
ch := make(chan struct{}, 1)
go func() {
cmd.Wait()
ch <- struct{}{}
}()
select {
case <-ch:
return
case <-time.After(10 * time.Second):
beeLogger.Log.Info("Timeout; Force kill cmd process")
err := cmd.Process.Kill() err := cmd.Process.Kill()
if err != nil { if err != nil {
beeLogger.Log.Errorf("Error while killing cmd process: %s", err) beeLogger.Log.Errorf("Error while killing cmd process: %s", err)
} }
return
}
} }
} }

View File

@ -32,7 +32,7 @@ import (
"strings" "strings"
"unicode" "unicode"
"gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
"github.com/astaxie/beego/swagger" "github.com/astaxie/beego/swagger"
"github.com/astaxie/beego/utils" "github.com/astaxie/beego/utils"
@ -124,7 +124,7 @@ func ParsePackagesFromDir(dirpath string) {
err = parsePackageFromDir(fpath) err = parsePackageFromDir(fpath)
if err != nil { if err != nil {
// Send the error to through the channel and continue walking // Send the error to through the channel and continue walking
c <- fmt.Errorf("Error while parsing directory: %s", err.Error()) c <- fmt.Errorf("error while parsing directory: %s", err.Error())
return nil return nil
} }
} }
@ -541,7 +541,7 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error {
//TODO: resultMap := buildParamMap(f.Type.Results) //TODO: resultMap := buildParamMap(f.Type.Results)
if comments != nil && comments.List != nil { if comments != nil && comments.List != nil {
for _, c := range comments.List { for _, c := range comments.List {
t := strings.TrimSpace(strings.TrimLeft(c.Text, "//")) t := strings.TrimSpace(strings.TrimPrefix(c.Text, "//"))
if strings.HasPrefix(t, "@router") { if strings.HasPrefix(t, "@router") {
elements := strings.TrimSpace(t[len("@router"):]) elements := strings.TrimSpace(t[len("@router"):])
e1 := strings.SplitN(elements, " ", 2) e1 := strings.SplitN(elements, " ", 2)

View File

@ -328,7 +328,7 @@ func CheckEnv(appname string) (apppath, packpath string, err error) {
apppath = filepath.Join(gosrcpath, appname) apppath = filepath.Join(gosrcpath, appname)
if _, e := os.Stat(apppath); !os.IsNotExist(e) { if _, e := os.Stat(apppath); !os.IsNotExist(e) {
err = fmt.Errorf("Cannot create application without removing '%s' first", apppath) err = fmt.Errorf("cannot create application without removing '%s' first", apppath)
beeLogger.Log.Errorf("Path '%s' already exists", apppath) beeLogger.Log.Errorf("Path '%s' already exists", apppath)
return return
} }