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
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.
generate the scheduler daemon files in your rails app:
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
- Settings file for certain variables like log directory
- dynamically add and remove tasks while daemon is running (? anyone want this?)
- tinder/campfire integration
Special thanks to Goldstar for sponsoring the plugin and promoting open-sourcesness.