Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
a Rails 2.3, Rails 3, and Ruby compatible scheduler daemon. Replaces cron/rake pattern of periodically running rake tasks to perform maintenance tasks, only loading the environment ONCE!
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators
lib
spec
.gitignore
CHANGES
MIT-LICENSE
README.markdown
Rakefile
VERSION
init.rb
install.rb
scheduler_daemon.gemspec
uninstall.rb

README.markdown

Scheduler Daemon

Rails 2.3.2 compatible scheduler daemon. Replaces cron/rake pattern of periodically running rake tasks to perform maintenance tasks in Rails apps. Scheduler Daemon is made specifically for your Rails app, and only loads the environment once, no matter how many tasks run.

What's so great about it? Well, I'm glad you asked!

  • Only loads your Rails environment once on daemon start, not every time a task is run
  • Allows you to easily deploy the scheduled tasks with your Rails app instead of depending on an administrator to update crontab
  • It doesn't use rake or cron!
  • Gets you up and running with your own daemon in under 2 minutes

Setup

Install the plugin

script/plugin install git://github.com/ssoroka/scheduler_daemon.git

Install required gems

gem sources -a http://gems.github.com # if you haven't already...

sudo gem install daemons rufus-scheduler eventmachine chronic

If you want to be able to use english time descriptions in your scheduled tasks, like:

scheduler.every '3h', :first_at => Chronic.parse('midnight')

then install Chronic:

sudo gem install chronic

Add the following line to your .gitignore since logs and pids get written there.

scheduler/log

generate the scheduler daemon files in your rails app:

script/generate scheduler

Usage

generate a new scheduled task:

script/generate scheduler_task MyTaskName

fire up the daemon in console mode to test it out

ruby scheduler/bin/scheduler_daemon.rb run

When you're done, get your system admin (or switch hats) to add the daemon to the system start-up, and capistrano deploy scripts, etc. Something like:

RAILS_ENV=production ruby /path/to/rails/app/scheduler/bin/scheduler_daemon.rb start

Test individual tasks like so:

ruby daemons/bin/task_runner.rb run -- --only=task_name1,task_name2

To Do

  • Settings file for certain variables like log directory
  • dynamically add and remove tasks while daemon is running (? anyone want this?)
  • tinder/campfire integration

Author

Steven Soroka

Thanks

Special thanks to Goldstar for sponsoring the plugin and promoting open-sourcesness.

Something went wrong with that request. Please try again.