Skip to content

Commit 4d7f7f6

Browse files
committed
Document how to change the class to run command recurring tasks
Fixes #356
1 parent ed636c3 commit 4d7f7f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,15 @@ MyJob.perform_later(42, status: "custom_status")
504504

505505
- `priority`: a numeric priority value to be used when enqueuing the job.
506506

507-
508507
Tasks are enqueued at their corresponding times by the scheduler, and each task schedules the next one. This is pretty much [inspired by what GoodJob does](https://github.com/bensheldon/good_job/blob/994ecff5323bf0337e10464841128fda100750e6/lib/good_job/cron_manager.rb).
509508

509+
For recurring tasks defined as a `command`, you can also change the job class that runs them as follows:
510+
```ruby
511+
Rails.application.config.after_initialize do # or to_prepare
512+
SolidQueue::RecurringTask.default_job_class = MyRecurringCommandJob
513+
end
514+
```
515+
510516
It's possible to run multiple schedulers with the same `recurring_tasks` configuration, for example, if you have multiple servers for redundancy, and you run the `scheduler` in more than one of them. To avoid enqueuing duplicate tasks at the same time, an entry in a new `solid_queue_recurring_executions` table is created in the same transaction as the job is enqueued. This table has a unique index on `task_key` and `run_at`, ensuring only one entry per task per time will be created. This only works if you have `preserve_finished_jobs` set to `true` (the default), and the guarantee applies as long as you keep the jobs around.
511517

512518
**Note**: a single recurring schedule is supported, so you can have multiple schedulers using the same schedule, but not multiple schedulers using different configurations.

0 commit comments

Comments
 (0)