#144 fixed
This commit is contained in:
parent
b26e4c877a
commit
6a2b11cbb2
|
@ -51,9 +51,8 @@ type Project struct {
|
||||||
stop chan bool
|
stop chan bool
|
||||||
files int64
|
files int64
|
||||||
folders int64
|
folders int64
|
||||||
lastFile string
|
last last
|
||||||
paths []string
|
paths []string
|
||||||
lastTime time.Time
|
|
||||||
Name string `yaml:"name" json:"name"`
|
Name string `yaml:"name" json:"name"`
|
||||||
Path string `yaml:"path" json:"path"`
|
Path string `yaml:"path" json:"path"`
|
||||||
Environment map[string]string `yaml:"environment,omitempty" json:"environment,omitempty"`
|
Environment map[string]string `yaml:"environment,omitempty" json:"environment,omitempty"`
|
||||||
|
@ -64,6 +63,12 @@ type Project struct {
|
||||||
ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"`
|
ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Last is used to save info about last file changed
|
||||||
|
type last struct{
|
||||||
|
file string
|
||||||
|
time time.Time
|
||||||
|
}
|
||||||
|
|
||||||
// Response exec
|
// Response exec
|
||||||
type Response struct {
|
type Response struct {
|
||||||
Name string
|
Name string
|
||||||
|
@ -286,9 +291,9 @@ L:
|
||||||
select {
|
select {
|
||||||
case event := <-p.watcher.Events():
|
case event := <-p.watcher.Events():
|
||||||
if p.parent.Settings.Recovery.Events {
|
if p.parent.Settings.Recovery.Events {
|
||||||
log.Println("Event:", event, "File:", event.Name, "LastFile:", p.lastFile, "Time:", time.Now(), "LastTime:", p.lastTime)
|
log.Println("File:", event.Name, "LastFile:", p.last.file, "Time:", time.Now(), "LastTime:", p.last.time)
|
||||||
}
|
}
|
||||||
if time.Now().Truncate(time.Second).After(p.lastTime) || event.Name != p.lastFile {
|
if time.Now().Truncate(time.Second).After(p.last.time) {
|
||||||
// switch event type
|
// switch event type
|
||||||
switch event.Op {
|
switch event.Op {
|
||||||
case fsnotify.Chmod:
|
case fsnotify.Chmod:
|
||||||
|
@ -310,15 +315,13 @@ L:
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
filepath.Walk(event.Name, p.walk)
|
filepath.Walk(event.Name, p.walk)
|
||||||
} else {
|
} else {
|
||||||
if event.Op != fsnotify.Write || event.Name != p.lastFile {
|
|
||||||
// stop and restart
|
// stop and restart
|
||||||
close(p.stop)
|
close(p.stop)
|
||||||
p.stop = make(chan bool)
|
p.stop = make(chan bool)
|
||||||
p.Change(event)
|
p.Change(event)
|
||||||
go p.Reload(event.Name, p.stop)
|
go p.Reload(event.Name, p.stop)
|
||||||
}
|
p.last.time = time.Now().Truncate(time.Second)
|
||||||
p.lastTime = time.Now().Truncate(time.Second)
|
p.last.file = event.Name
|
||||||
p.lastFile = event.Name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,6 +482,9 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
||||||
if p.Validate(path, true) {
|
if p.Validate(path, true) {
|
||||||
result := p.watcher.Walk(path, p.init)
|
result := p.watcher.Walk(path, p.init)
|
||||||
if result != "" {
|
if result != "" {
|
||||||
|
if p.parent.Settings.Recovery.Index {
|
||||||
|
log.Println("Indexing",path)
|
||||||
|
}
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
// tools dir
|
// tools dir
|
||||||
p.tools(p.stop, path, info)
|
p.tools(p.stop, path, info)
|
||||||
|
|
Loading…
Reference in New Issue