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
If a static schedule is not set `resque-scheduler` will issue a "Schedule empty!" warning on
316
316
startup, but despite that warning setting a static schedule is totally optional. It is possible
317
-
to use only dynamic schedules (see below).
317
+
to use only dynamic schedules or auto load (see below).
318
318
319
319
The schedule file is a list of Resque job classes with arguments and a
320
320
schedule frequency (in crontab syntax). The schedule is just a hash, but
@@ -445,6 +445,50 @@ config[:every] = '1d'
445
445
Resque.set_schedule(name, config)
446
446
```
447
447
448
+
#### Auto load
449
+
450
+
With auto load you specify a path from which jobs will be loaded and scheduled without the needs of static scheduling or dynamic scheduling.
451
+
452
+
Auto load are not enabled by default. To be able to auto load set schedules, you must pass the following to resque-scheduler initialization (see Installation above for a more complete example):
453
+
454
+
```ruby
455
+
Resque::Scheduler.auto_load = 'path/to/*_job.rb'
456
+
```
457
+
458
+
Auto load enables a job to declare it's scheduling. In order to do that file must follow `snake_case` convention for filename and `CamelCase` for class name. It also must include `Resque::Scheduler::Job` and declares it's schedule:
459
+
460
+
```ruby
461
+
cron '*/2 * * * *'
462
+
queue 'default'
463
+
```
464
+
465
+
All options available:
466
+
467
+
```ruby
468
+
cron '* */3 * * *' # use cron or every option, don't use both
469
+
every '3d' # use every or cron option, don't use both
470
+
queue 'default'
471
+
args 'custom arg'
472
+
description 'Nice description'
473
+
```
474
+
475
+
Job's example:
476
+
477
+
```ruby
478
+
# my_great_job.rb
479
+
require 'resque/scheduler/job'
480
+
481
+
class MyGreatJob
482
+
include Resque::Scheduler::Job
483
+
484
+
cron '*/2 * * * *'
485
+
queue 'default'
486
+
args 'args'
487
+
description 'description'
488
+
end
489
+
490
+
```
491
+
448
492
#### Time zones
449
493
450
494
If you use the cron syntax, by default it is interpreted in the server time zone.
0 commit comments