Skip to content

Commit

Permalink
fix jiraJob does not check for changes in dashboards sub folders
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeantet committed Jul 18, 2016
1 parent 8c1bd39 commit ba5b92e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@

# added by GitSavvy
/dashing.exe

# added by GitSavvy
/jobs/5_sampleTXT.php
40 changes: 5 additions & 35 deletions jobs/JiraIssueCount.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"strconv"
"time"

"gopkg.in/fsnotify.v1"

"github.com/BurntSushi/toml"
"github.com/PuerkitoBio/goquery"
"github.com/andygrunwald/go-jira"
Expand Down Expand Up @@ -57,12 +55,11 @@ func (j *jiraIssueCount) Work(send chan *dashing.Event, webroot string, url stri
j.readIndicators(webroot + "dashboards/")
j.pushData(send)

go j.watchChanges(webroot + "dashboards/")

ticker := time.NewTicker(time.Duration(j.config.Interval) * time.Second)
for {
select {
case <-ticker.C:
j.readIndicators(webroot + "dashboards/")
j.pushData(send)
}
}
Expand Down Expand Up @@ -137,7 +134,9 @@ func (j *jiraIssueCount) readIndicators(dashroot string) {
}

// open each gerb
files, _ := filepath.Glob(dashroot + "*.gerb")
files, _ := filepath.Glob(dashroot + "**/*.gerb")
files2, _ := filepath.Glob(dashroot + "*.gerb")
files = append(files, files2...)
for _, file := range files {
reader, err := os.Open(file)
if err != nil {
Expand All @@ -146,6 +145,7 @@ func (j *jiraIssueCount) readIndicators(dashroot string) {
}

doc, err := goquery.NewDocumentFromReader(reader)
reader.Close()
if err != nil {
log.Println("JiraJob : error goquery file : " + err.Error())
continue
Expand Down Expand Up @@ -208,37 +208,7 @@ func (j *jiraIssueCount) readIndicators(dashroot string) {
WarningOver: warningOver,
})
})

}
}

func (j *jiraIssueCount) watchChanges(dashroot string) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()

done := make(chan bool)
go func() {
for {
select {
case event := <-watcher.Events:
if event.Op&fsnotify.Write == fsnotify.Write {
j.readIndicators(dashroot)
}
case err := <-watcher.Errors:
log.Println("JiraJob : error:", err)
}
}
}()

err = watcher.Add(dashroot)
if err != nil {
log.Println(err)
}
<-done

}

func init() {
Expand Down

0 comments on commit ba5b92e

Please sign in to comment.