Sha256: 64e135651a801272873f2012b69af3cdaf1fd358a1e3f663b7c38814ac5a757a

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

require "rufus/scheduler"

Houston.daemonize "scheduler" do
  $scheduler = Rufus::Scheduler.new

  Houston.config.timers.each do |(type, param, name, options, block)|
    wrapped_block = Houston.jobs.method(:run)

    case type
    when :cron
      cronline = Whenever::Output::Cron.new(options.fetch(:every, :day), nil, param)
      $scheduler.cron cronline.time_in_cron_syntax, options.merge(tag: name), &wrapped_block

    when :every
      $scheduler.every param, options.merge(tag: name), &wrapped_block

    else
      raise NotImplementedError, "A #{type.inspect} timer is not implemented"
    end
  end

  $scheduler.join
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
houston-core-0.7.0.beta3 config/initializers/houston_scheduler.rb
houston-core-0.7.0.beta2 config/initializers/houston_scheduler.rb
houston-core-0.7.0.beta config/initializers/houston_scheduler.rb