Class: DaemonKit::Cron
Overview
Thin wrapper around rufus-scheduler gem, specifically designed to ease configuration of a scheduler and provide some added simplicity.
For more information on rufus-scheduler, please visit the RDoc’s at rufus.rubyforge.org/rufus-scheduler/
To use the evented scheduler, call #DaemonKit::EM.run prior to setting up your first schedule.
Instance Attribute Summary collapse
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Class Method Summary collapse
-
.instance ⇒ Object
Access to the scheduler instance.
-
.run ⇒ Object
Once the scheduler has been configured, call #run to block the current thread and keep the process alive for the scheduled tasks to run.
- .scheduler ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Cron
constructor
A new instance of Cron.
Constructor Details
#initialize ⇒ Cron
Returns a new instance of Cron.
44 45 46 |
# File 'lib/daemon_kit/cron.rb', line 44 def initialize @scheduler = Rufus::Scheduler.start_new end |
Instance Attribute Details
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
15 16 17 |
# File 'lib/daemon_kit/cron.rb', line 15 def scheduler @scheduler end |
Class Method Details
.instance ⇒ Object
Access to the scheduler instance
20 21 22 |
# File 'lib/daemon_kit/cron.rb', line 20 def instance @instance ||= new end |
.run ⇒ Object
Once the scheduler has been configured, call #run to block the current thread and keep the process alive for the scheduled tasks to run
33 34 35 36 37 38 39 40 41 |
# File 'lib/daemon_kit/cron.rb', line 33 def run DaemonKit.logger.info "Starting rufus-scheduler" if instance.is_a?( Rufus::Scheduler::PlainScheduler ) instance.scheduler.join else Thread.stop end end |
.scheduler ⇒ Object
24 25 26 |
# File 'lib/daemon_kit/cron.rb', line 24 def scheduler instance.scheduler end |