From 6a2b11cbb277400ff44d9dde5376ad5dc12c905e Mon Sep 17 00:00:00 2001 From: asoseil Date: Sun, 14 Jan 2018 09:36:19 +0100 Subject: [PATCH 1/4] #144 fixed --- realize/projects.go | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/realize/projects.go b/realize/projects.go index 1ef974c..b11c0b2 100644 --- a/realize/projects.go +++ b/realize/projects.go @@ -51,9 +51,8 @@ type Project struct { stop chan bool files int64 folders int64 - lastFile string + last last paths []string - lastTime time.Time Name string `yaml:"name" json:"name"` Path string `yaml:"path" json:"path"` 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"` } +// Last is used to save info about last file changed +type last struct{ + file string + time time.Time +} + // Response exec type Response struct { Name string @@ -286,9 +291,9 @@ L: select { case event := <-p.watcher.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.Op { case fsnotify.Chmod: @@ -310,15 +315,13 @@ L: if fi.IsDir() { filepath.Walk(event.Name, p.walk) } else { - if event.Op != fsnotify.Write || event.Name != p.lastFile { - // stop and restart - close(p.stop) - p.stop = make(chan bool) - p.Change(event) - go p.Reload(event.Name, p.stop) - } - p.lastTime = time.Now().Truncate(time.Second) - p.lastFile = event.Name + // stop and restart + close(p.stop) + p.stop = make(chan bool) + p.Change(event) + go p.Reload(event.Name, p.stop) + p.last.time = time.Now().Truncate(time.Second) + p.last.file = event.Name } } } @@ -479,6 +482,9 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error { if p.Validate(path, true) { result := p.watcher.Walk(path, p.init) if result != "" { + if p.parent.Settings.Recovery.Index { + log.Println("Indexing",path) + } if info.IsDir() { // tools dir p.tools(p.stop, path, info) From 28d22a026f9f0c0574d1d76bdd0b3ffd1e842b96 Mon Sep 17 00:00:00 2001 From: asoseil Date: Sun, 14 Jan 2018 09:36:46 +0100 Subject: [PATCH 2/4] recovery index options --- realize/settings.go | 1 + 1 file changed, 1 insertion(+) diff --git a/realize/settings.go b/realize/settings.go index bdc10eb..d30db6c 100644 --- a/realize/settings.go +++ b/realize/settings.go @@ -35,6 +35,7 @@ type Settings struct { } type Recovery struct { + Index bool Events bool Tools bool } From a2545b646681694350c7e6a32d57515fdd6bee43 Mon Sep 17 00:00:00 2001 From: asoseil Date: Sun, 14 Jan 2018 09:37:13 +0100 Subject: [PATCH 3/4] config updated with files indexing --- .realize.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.realize.yaml b/.realize.yaml index a2586d8..f9cd063 100755 --- a/.realize.yaml +++ b/.realize.yaml @@ -1,7 +1,8 @@ settings: recovery: - events: true - tools: true + index: true + events: false + tools: false legacy: force: false interval: 0s @@ -15,7 +16,7 @@ schema: path: . commands: generate: - status: false + status: true install: status: true vet: @@ -35,5 +36,7 @@ schema: ignored_paths: - .git - .realize + - .idea - vendor - realize/assets + - realize/bindata.go From bfc49f733891ebeb48d28bcfe6ff747c01d143c9 Mon Sep 17 00:00:00 2001 From: asoseil Date: Sun, 14 Jan 2018 09:41:46 +0100 Subject: [PATCH 4/4] field comments --- .realize.yaml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.realize.yaml b/.realize.yaml index f9cd063..ff17141 100755 --- a/.realize.yaml +++ b/.realize.yaml @@ -1,39 +1,39 @@ settings: recovery: - index: true - events: false - tools: false + index: true # print files indexing + events: false # print each event + tools: false # print each tool legacy: - force: false - interval: 0s + force: false # enable polling watcher + interval: 0s # polling interval server: - status: false - open: true - port: 3000 - host: localhost + status: false # web panel + open: true # open in default browser + port: 3000 # server port + host: localhost # server host schema: -- name: realize - path: . - commands: - generate: +- name: realize # project name + path: . # project path, '.' is for wdir path + commands: # all go commands supported + generate: # go generate status: true - install: + install: # go install status: true - vet: + vet: # go vet status: true - test: + test: # go test status: true - fmt: + fmt: # go fmt status: true watcher: - paths: + paths: # paths watched - / - extensions: + extensions: # extensions watched - go - html - css - js - ignored_paths: + ignored_paths: # paths ignored - .git - .realize - .idea