Changed forced build to be only off of trigger

instead of anytime that it's not polled
This commit is contained in:
Tim Shannon 2016-05-05 10:30:50 -05:00
parent b1c259640e
commit 479175baa0
3 changed files with 10 additions and 10 deletions

View File

@ -27,7 +27,7 @@ Project life cycle:
// load is the beginning of the cycle. Loads / reloads the project file to make sure that the scripts are up-to-date // load is the beginning of the cycle. Loads / reloads the project file to make sure that the scripts are up-to-date
// call's fetch and triggers the next poll if one exists // call's fetch and triggers the next poll if one exists
func (p *Project) load() { func (p *Project) load(forceBuild bool) {
p.processing.Lock() // ensure only one cycle is running at a time per project p.processing.Lock() // ensure only one cycle is running at a time per project
defer p.processing.Unlock() defer p.processing.Unlock()
@ -64,7 +64,7 @@ func (p *Project) load() {
p.setData(new) p.setData(new)
p.fetch() p.fetch(forceBuild)
p.setStage(stageWait) p.setStage(stageWait)
@ -73,16 +73,16 @@ func (p *Project) load() {
if p.poll > 0 { if p.poll > 0 {
//start polling //start polling
go func() { time.AfterFunc(p.poll, func() {
time.AfterFunc(p.poll, p.load) p.load(false)
}() })
} }
} }
// fetch first runs the fetch script into a temporary directory // fetch first runs the fetch script into a temporary directory
// then it runs the version script in the temp directory to see if there is a newer version of the // then it runs the version script in the temp directory to see if there is a newer version of the
// fetched code, if there is then the temp dir is renamed to the version name // fetched code, if there is then the temp dir is renamed to the version name
func (p *Project) fetch() { func (p *Project) fetch(forceBuild bool) {
p.setStage(stageFetch) p.setStage(stageFetch)
p.start = time.Now() p.start = time.Now()
@ -111,8 +111,8 @@ func (p *Project) fetch() {
p.setVersion(strings.TrimSpace(string(version))) p.setVersion(strings.TrimSpace(string(version)))
if p.poll > 0 { if !forceBuild {
// if polling, check if this specific version has attempted a build yet // if not forced build, then check if this specific version has attempted a build yet
lVer, err := p.ds.LastVersion(stageBuild) lVer, err := p.ds.LastVersion(stageBuild)
if err != datastore.ErrNotFound && p.errHandled(err) { if err != datastore.ErrNotFound && p.errHandled(err) {
return return

View File

@ -427,7 +427,7 @@ func (p *projectList) add(name string) {
log.Printf("Error opening datastore for Project: %s Error: %s\n", prj.id(), err) log.Printf("Error opening datastore for Project: %s Error: %s\n", prj.id(), err)
return return
} }
prj.load() prj.load(false)
}() }()
} }

View File

@ -259,6 +259,6 @@ func triggerPost(w http.ResponseWriter, r *http.Request) {
} }
go func() { go func() {
project.load() project.load(true)
}() }()
} }