You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
We use Whenever on a large project with lots of scheduled tasks on different hours. For example at 9am :
every :day, at: '09:00am' do
runner 'MyClass1.task1'
runner 'MyClass2.task2'
...
runner 'MyClass10.task10'
end
The problem is that this creates 10 cron tasks at 9am, and lots of processes are spawned simultaneously and uses a lot of RAM.
So instead we would like to run a single cron task with 10 chained tasks.
I thought we could use the following syntax (untested) :
every :day, at: '09:00am' do
runner 'MyClass1.task1; MyClass2.task2'; ...; MyClass10.task10'
end
But this would make long lines and the code would hardly be readable.
We could also create a Ruby class, say "SchedulerTask" and create a static method , say "SchedulerTask.9am", and then use it the scheduler, but I find this not very elegant.
Is there any good practice to do that ? (I've search the issues, but couldn't find...)
Thank you for your help :)
Mathieu.
The text was updated successfully, but these errors were encountered:
I don’t think the gem supports that internally. What you suggest works well. You can create a class or rake task that has a sequence of operations to run that would execute sequentially.
Remember that these are cron jobs as well instead of other types of architecture. You can also create your own cron tab command through the gem and chain them by manually setting it as defined in the wiki.
njakobsen
added a commit
to combinaut/whenever
that referenced
this issue
Jul 31, 2024
Jobs now support a `sequence` option that will cause jobs with the same `sequence` value to run sequentially when scheduled for the same time. `sequential: true` can be passed to the `every` block to automatically set a common `sequence` value for each contained job.
Closesjavan#696Closesjavan#835
njakobsen
added a commit
to combinaut/whenever
that referenced
this issue
Jul 31, 2024
Jobs now support a `sequence` option that will cause jobs with the same `sequence` value to run sequentially when scheduled for the same time. `sequential: true` can be passed to the `every` block to automatically set a common `sequence` value for each contained job.
Closesjavan#19Closesjavan#696Closesjavan#835
Hello,
We use Whenever on a large project with lots of scheduled tasks on different hours. For example at 9am :
The problem is that this creates 10 cron tasks at 9am, and lots of processes are spawned simultaneously and uses a lot of RAM.
So instead we would like to run a single cron task with 10 chained tasks.
I thought we could use the following syntax (untested) :
But this would make long lines and the code would hardly be readable.
We could also create a Ruby class, say "SchedulerTask" and create a static method , say "SchedulerTask.9am", and then use it the scheduler, but I find this not very elegant.
Is there any good practice to do that ? (I've search the issues, but couldn't find...)
Thank you for your help :)
Mathieu.
The text was updated successfully, but these errors were encountered: