Skip to content

Commit

Permalink
make the start of cron runner behavior configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 21, 2024
1 parent fabd256 commit 2155872
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,19 @@ const (
var (
EvictedJobs chan uuid.UUID
startedJobHistory = false

// startCronOnSchedule dictates whether to start the cron runner
// when a job is scheduled to it.
startCronOnSchedule = true
)

// DisableCronStartOnSchedule disables the default bahevior of
// starting the cron runner when a job is scheduled via
// `.AddToSchduler()`
func DisableCronStartOnSchedule() {
startCronOnSchedule = false
}

func StartJobHistoryEvictor(ctx context.Context) {
if !startedJobHistory {
if EvictedJobs == nil {
Expand Down Expand Up @@ -563,6 +574,9 @@ func (j *Job) GetResourcedName() string {

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

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

0 comments on commit 2155872

Please sign in to comment.