summaryrefslogtreecommitdiff
path: root/jobs.go
diff options
context:
space:
mode:
Diffstat (limited to 'jobs.go')
-rw-r--r--jobs.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/jobs.go b/jobs.go
index 8d0bf13..46ed7dc 100644
--- a/jobs.go
+++ b/jobs.go
@@ -22,19 +22,19 @@ func JobScheduler(quitChannel chan int) {
JobIdCloseDecisions: NewCloseDecisionsJob(),
JobIdRemindVotersJob: NewRemindVotersJob(),
}
- logger.Infof("started job scheduler")
+ log.Info("started job scheduler")
for {
select {
case jobId := <-rescheduleChannel:
job := jobs[jobId]
- logger.Infof("reschedule job %s", job)
+ log.Infof("reschedule job %s", job)
job.Schedule()
case <-quitChannel:
for _, job := range jobs {
job.Stop()
}
- logger.Infof("stop job scheduler")
+ log.Info("stop job scheduler")
return
}
}
@@ -54,7 +54,7 @@ func (j *CloseDecisionsJob) Schedule() {
var nextDue *time.Time
nextDue, err := GetNextPendingDecisionDue()
if err != nil {
- logger.Errorf("Could not get next pending due date")
+ log.Error("Could not get next pending due date")
if j.timer != nil {
j.timer.Stop()
j.timer = nil
@@ -62,11 +62,11 @@ func (j *CloseDecisionsJob) Schedule() {
return
}
if nextDue == nil {
- logger.Infof("no next planned execution of CloseDecisionsJob")
+ log.Info("no next planned execution of CloseDecisionsJob")
j.Stop()
} else {
- nextDue := nextDue.Add(time.Minute)
- logger.Infof("scheduling CloseDecisionsJob for %s", nextDue)
+ nextDue := nextDue.Add(time.Second)
+ log.Infof("scheduling CloseDecisionsJob for %s", nextDue)
when := nextDue.Sub(time.Now())
if j.timer != nil {
j.timer.Reset(when)
@@ -84,10 +84,10 @@ func (j *CloseDecisionsJob) Stop() {
}
func (j *CloseDecisionsJob) Run() {
- logger.Infof("running CloseDecisionsJob")
+ log.Debug("running CloseDecisionsJob")
err := CloseDecisions()
if err != nil {
- logger.Errorf("closing decisions %s", err)
+ log.Errorf("closing decisions %v", err)
}
rescheduleChannel <- JobIdCloseDecisions
}
@@ -109,7 +109,7 @@ func NewRemindVotersJob() *RemindVotersJob {
func (j *RemindVotersJob) Schedule() {
year, month, day := time.Now().UTC().Date()
nextExecution := time.Date(year, month, day, 0, 0, 0, 0, time.UTC).AddDate(0, 0, 3)
- logger.Infof("scheduling RemindVotersJob for %s", nextExecution)
+ log.Infof("scheduling RemindVotersJob for %s", nextExecution)
when := nextExecution.Sub(time.Now())
if j.timer != nil {
j.timer.Reset(when)
@@ -126,19 +126,19 @@ func (j *RemindVotersJob) Stop() {
}
func (j *RemindVotersJob) Run() {
- logger.Infof("running RemindVotersJob")
+ log.Info("running RemindVotersJob")
defer func() { rescheduleChannel <- JobIdRemindVotersJob }()
voters, err := GetReminderVoters()
if err != nil {
- logger.Errorf("problem getting voters %s", err)
+ log.Errorf("problem getting voters %v", err)
return
}
for _, voter := range *voters {
decisions, err := FindUnvotedDecisionsForVoter(&voter)
if err != nil {
- logger.Errorf("problem getting unvoted decisions")
+ log.Errorf("problem getting unvoted decisions: %v", err)
return
}
if len(*decisions) > 0 {