Awesome
puma-rufus-scheduler
Puma plugin to run Rufus Scheduler.
Installation
- Add this line to your application's Gemfile:
gem "puma-rufus-scheduler"
- Install dependencies with bundler:
bundle install
- Add the following line to your
config/puma.rb
:
plugin "rufus-scheduler"
- Create your scheduler file in
config/scheduler.rb
:
scheduler = Rufus::Scheduler.new
scheduler.every "5s" do
puts "Every 5 seconds #{Time.current}"
end
# This will attach scheduler thread to Puma's background thread.
# Dont forget to add this line!
scheduler.join
- Start your Puma server and you should see the scheduler running:
$ bin/rails server
=> Booting Puma
=> Rails 7.1.3.2 application starting in development
...
Every 5 seconds 2024-04-17 14:13:11 UTC
Every 5 seconds 2024-04-17 14:13:16 UTC
Every 5 seconds 2024-04-17 14:13:21 UTC
Configuration
You can change the scheduler file path by setting the RUFUS_SCHEDULER_FILE
environment variable:
RUFUS_SCHEDULER_FILE=config/my_scheduler.rb bin/rails server
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/rake test
to run the tests.
To install this gem onto your local machine, run bin/rake install
.
To release a new version, update the version number in version.rb
, and then run bin/rake release
,
which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to
rubygems.org.
License
Copyright © 2024 Javier Aranda. Released under the terms of the MIT license.