Skip to content

Commit

Permalink
Merge pull request #18 from uc-cdis/fix/completed_jobs
Browse files Browse the repository at this point in the history
fix(completed_jobs): increase time to harvest completed jobs
  • Loading branch information
giangbui authored Mar 20, 2020
2 parents ba402da + 6c917dd commit 416e5b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions handlers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (handler *SQSHandler) StartServer() error {
glog.Info("The server is started")

go handler.StartMonitoringProcess()
go handler.RemoveCompletedJobsProcess()

return nil

Expand All @@ -93,12 +94,19 @@ func (handler *SQSHandler) StartMonitoringProcess() {
handler.MonitoredJobs = nextMonitoredJobs
handler.Mu.Unlock()

RemoveCompletedJobs()

time.Sleep(30 * time.Second)
}
}

// RemoveCompletedJobsProcess starts the process to remove completed jobs
func (handler *SQSHandler) RemoveCompletedJobsProcess() {
for {
time.Sleep(300 * time.Second)
glog.Info("Start to remove completed jobs")
RemoveCompletedJobs()
}
}

// ShutdownServer shutdowns a server
func (handler *SQSHandler) ShutdownServer() error {
fmt.Println("Shutdown the server")
Expand Down
2 changes: 1 addition & 1 deletion handlers/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func GetNumberRunningJobs() int {
nRunningJobs := 0
for i := 0; i < len(jobs.JobInfo); i++ {
job := jobs.JobInfo[i]
if job.Status == "Running" {
if job.Status == "Running" || job.Status == "Unknown" {
nRunningJobs++
}
}
Expand Down

0 comments on commit 416e5b2

Please sign in to comment.