realize run fixed
This commit is contained in:
parent
434fe5f43e
commit
64ad2dcaf3
|
@ -15,9 +15,9 @@ func (h *Blueprint) Run() error {
|
|||
if err == nil {
|
||||
// loop projects
|
||||
wg.Add(len(h.Projects))
|
||||
for _, v := range h.Projects {
|
||||
v.parent = h
|
||||
go v.watching()
|
||||
for k := range h.Projects {
|
||||
h.Projects[k].parent = h
|
||||
go h.Projects[k].watching()
|
||||
}
|
||||
wg.Wait()
|
||||
return nil
|
||||
|
|
|
@ -29,10 +29,10 @@ func (p *Project) GoRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
|||
build.Dir = p.base
|
||||
defer func() {
|
||||
if err := build.Process.Kill(); err != nil {
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, "Failed to stop: "+err.Error())
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Failed to stop: " + err.Error()})
|
||||
log.Fatal(Red("Failed to stop: "), Red(err))
|
||||
}
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, "Ended")
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Ended"})
|
||||
log.Println(pname(p.Name, 2), ":", RedS("Ended"))
|
||||
go sync()
|
||||
wr.Done()
|
||||
|
@ -59,9 +59,9 @@ func (p *Project) GoRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
|||
select {
|
||||
default:
|
||||
if isError {
|
||||
p.Buffer.StdErr = append(p.Buffer.StdErr, output.Text())
|
||||
p.Buffer.StdErr = append(p.Buffer.StdErr, BufferOut{Time: time.Now(), Text: output.Text()})
|
||||
} else {
|
||||
p.Buffer.StdOut = append(p.Buffer.StdOut, output.Text())
|
||||
p.Buffer.StdOut = append(p.Buffer.StdOut, BufferOut{Time: time.Now(), Text: output.Text()})
|
||||
}
|
||||
go sync()
|
||||
|
||||
|
@ -80,6 +80,7 @@ func (p *Project) GoRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
|||
}
|
||||
close(stop)
|
||||
}
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Started"})
|
||||
go scanner(stopOutput, execOutput, false)
|
||||
go scanner(stopError, execError, true)
|
||||
|
||||
|
|
15
cli/main.go
15
cli/main.go
|
@ -26,12 +26,12 @@ type logWriter struct{}
|
|||
type Blueprint struct {
|
||||
Projects []Project `yaml:"projects,omitempty"`
|
||||
Files map[string]string `yaml:"-"`
|
||||
Sync chan string
|
||||
Sync chan string `yaml:"-"`
|
||||
}
|
||||
|
||||
// Project defines the informations of a single project
|
||||
type Project struct {
|
||||
LastChangedOn time.Time
|
||||
LastChangedOn time.Time `yaml:"-"`
|
||||
base string
|
||||
Name string `yaml:"app_name,omitempty"`
|
||||
Path string `yaml:"app_path,omitempty"`
|
||||
|
@ -60,9 +60,14 @@ type Watcher struct {
|
|||
|
||||
// Buffer struct for buffering outputs
|
||||
type Buffer struct {
|
||||
StdOut []string
|
||||
StdLog []string
|
||||
StdErr []string
|
||||
StdOut []BufferOut
|
||||
StdLog []BufferOut
|
||||
StdErr []BufferOut
|
||||
}
|
||||
|
||||
type BufferOut struct {
|
||||
Time time.Time
|
||||
Text string
|
||||
}
|
||||
|
||||
// Initialize the application
|
||||
|
|
|
@ -18,6 +18,8 @@ import (
|
|||
// Watching method is the main core. It manages the livereload and the watching
|
||||
func (p *Project) watching() {
|
||||
|
||||
log.Println(p)
|
||||
|
||||
var wr sync.WaitGroup
|
||||
var watcher *fsnotify.Watcher
|
||||
|
||||
|
|
Loading…
Reference in New Issue