Home

Awesome

Simple scheduler for long-running and infrequent tasks.

Install

gem install serial_scheduler

Usage

require 'serial_scheduler'
scheduler = SerialScheduler.new

scheduler.add :foo, interval: 10, timeout: 2 do
  puts 'Doing foo'
end
scheduler.add :bar, interval: 5, timeout: 1 do
  puts 'Doing bar'
end

require 'fugit'
scheduler.add :bar, cron: "* * * * * America/New_York", timeout: 1 do
  puts 'Doing cron'
end

scheduler.run

Logging

SerialScheduler.new logger: my_logger

message: "Waiting to start job", job: :foo, in: 15, at: '2019-12-30 11:00:00'

Errors

Send to error service of your choice, or don't set it and it will raise and stop.

SerialScheduler.new error_handler: ->(e) { puts e }

Stopping

Will not start any new task, but finish the current one.

scheduler.stop

Author

Michael Grosser<br/> michael@grosser.it<br/> License: MIT<br/> Build Status