Skip to content

Commit

Permalink
fix: don't run cron on schedule
Browse files Browse the repository at this point in the history
need to explicitly start the cron to support multiple replicase (leader
election).

This way multiple replicas can register the job without starting it and
let the leader election start/stop the cron schedulers.
  • Loading branch information
adityathebe authored and moshloop committed Oct 22, 2024
1 parent 15e63f5 commit e8bfe65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ func (j *JobRuntime) end() {
j.Job.statusRing.Add(j.History)

j.Context.Counter("job", "name", j.Job.Name, "id", j.Job.ResourceID, "resource", j.Job.ResourceType, "status", j.History.Status).Add(1)
j.Context.Histogram("job_duration", context.LongLatencyBuckets, "name", j.Job.Name, "id", j.Job.ResourceID, "resource", j.Job.ResourceType, "status", j.History.Status).Since(j.History.TimeStart)
j.Context.Histogram("job_duration", context.LongLatencyBuckets, "name", j.Job.Name, "id", j.Job.ResourceID, "resource", j.Job.ResourceType, "status", j.History.Status).
Since(j.History.TimeStart)
}

func (j *JobRuntime) Failf(message string, args ...interface{}) {
Expand Down Expand Up @@ -562,7 +563,6 @@ func (j *Job) GetResourcedName() string {

func (j *Job) AddToScheduler(cronRunner *cron.Cron) error {
echo.RegisterCron(cronRunner)
cronRunner.Start()

schedule := j.Schedule
if override, ok := j.GetProperty("schedule"); ok {
Expand Down

0 comments on commit e8bfe65

Please sign in to comment.