run workflow fixed
This commit is contained in:
parent
9cd07380e5
commit
6239a165ce
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
type Project struct {
|
||||
reload time.Time
|
||||
Base string
|
||||
base string
|
||||
Name string `yaml:"app_name,omitempty"`
|
||||
Path string `yaml:"app_path,omitempty"`
|
||||
Main string `yaml:"app_main,omitempty"`
|
||||
|
@ -25,8 +25,17 @@ type Project struct {
|
|||
|
||||
func (p *Project) GoRun(channel chan bool, wr *sync.WaitGroup) error {
|
||||
name := strings.Split(p.Path, "/")
|
||||
build := exec.Command(name[len(name)-1], os.Getenv("PATH"))
|
||||
build.Dir = p.Base
|
||||
stop := make(chan bool,1)
|
||||
var run string
|
||||
|
||||
if len(name) == 1 {
|
||||
name := strings.Split(p.base, "/")
|
||||
run = name[len(name)-1]
|
||||
}else{
|
||||
run = name[len(name)-1]
|
||||
}
|
||||
build := exec.Command(os.Getenv("GOPATH")+slash("bin")+slash(run))
|
||||
build.Dir = p.base
|
||||
defer func() {
|
||||
if err := build.Process.Kill(); err != nil {
|
||||
log.Fatal("failed to stop: ", err)
|
||||
|
@ -51,11 +60,14 @@ func (p *Project) GoRun(channel chan bool, wr *sync.WaitGroup) error {
|
|||
log.Println(p.Name + ":", in.Text())
|
||||
}
|
||||
}
|
||||
close(stop)
|
||||
}()
|
||||
|
||||
for{
|
||||
select {
|
||||
case <-channel:
|
||||
case <- channel:
|
||||
return nil
|
||||
case <-stop:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -67,13 +79,13 @@ func (p *Project) GoBuild() error {
|
|||
var out bytes.Buffer
|
||||
|
||||
// create bin dir
|
||||
if _, err := os.Stat(p.Base + "/bin"); err != nil {
|
||||
if err = os.Mkdir(p.Base + "/bin", 0777); err != nil {
|
||||
if _, err := os.Stat(p.base + "/bin"); err != nil {
|
||||
if err = os.Mkdir(p.base + "/bin", 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
build := exec.Command("go", "build", p.Base + p.Main)
|
||||
build.Dir = p.Base + "/bin"
|
||||
build := exec.Command("go", "build", p.base + p.Main)
|
||||
build.Dir = p.base + "/bin"
|
||||
build.Stdout = &out
|
||||
if err := build.Run(); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue