mirror of
https://github.com/zrepl/zrepl.git
synced 2025-06-19 17:27:46 +02:00
jobrun: fix timing issue and minor printing issues
Would add offset by 1 sec (possibly to avoid being scheduled just a little bit too early). Turns out this leads to delays for jobs with interval < 2s :)
This commit is contained in:
parent
2c50c8fd63
commit
2b6f3ece6b
@ -102,7 +102,7 @@ loop:
|
|||||||
|
|
||||||
dueTime, resched := finishedJob.RepeatStrategy.ShouldReschedule(res)
|
dueTime, resched := finishedJob.RepeatStrategy.ShouldReschedule(res)
|
||||||
if resched {
|
if resched {
|
||||||
r.logger.Printf("[%s] rescheduling to %s", dueTime)
|
r.logger.Printf("[%s] rescheduling to %s", finishedJob.Name, dueTime)
|
||||||
finishedJob.DueAt = dueTime
|
finishedJob.DueAt = dueTime
|
||||||
r.pending[finishedJob.Name] = finishedJob
|
r.pending[finishedJob.Name] = finishedJob
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ loop:
|
|||||||
|
|
||||||
for jobName, job := range r.pending {
|
for jobName, job := range r.pending {
|
||||||
|
|
||||||
if job.DueAt.After(time.Now()) {
|
if job.DueAt.After(now) {
|
||||||
if job.DueAt.Before(nextJobDue) {
|
if job.DueAt.Before(nextJobDue) {
|
||||||
nextJobDue = job.DueAt
|
nextJobDue = job.DueAt
|
||||||
}
|
}
|
||||||
@ -150,7 +150,6 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if jobPending || len(r.running) > 0 {
|
if jobPending || len(r.running) > 0 {
|
||||||
nextJobDue = nextJobDue.Add(time.Second).Round(time.Second)
|
|
||||||
r.logger.Printf("waiting until %v\n", nextJobDue)
|
r.logger.Printf("waiting until %v\n", nextJobDue)
|
||||||
r.scheduleTimer = time.After(nextJobDue.Sub(now))
|
r.scheduleTimer = time.After(nextJobDue.Sub(now))
|
||||||
goto loop
|
goto loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user