firstruby

Master ruby with us

Archive for January, 2010

Do we really need BackgrounDRb now ? Craken plugin makes job easier in Ruby on Rails

Posted by firstruby on January 1, 2010

There was some issue with BackgrounDRb like Memory leakage, so it was braeking the cron jobs. There are alternatives to BackgrounDRb as Craken. Craken is best.

Craken is a Ruby on Rails plugin for managing and installing rake-centric crontab.

Craken Installation as,

./script/plugin install git://github.com/latimes/craken.git

Craken Configuration with Ruby on Rails app,
You need to write the RAKE task which needs to run after some intervals.
Suppose I have a RAKE task db:send_emails

Create Crontab file at following path,

#{RAILS_ROOT}/config/craken/raketab.yml

Add configuration to raketab.yml as,

my_config:
hour: 0
minute: *
day: *
month: *
command: db:send_emails > /tmp/db_send_emails.log 2>&1

Above configuration will run the “db:send_emails” tasks after very 24 hours (midnight)

Finally create the CRON job with following command,

rake craken:install

Above command will create a cronjob.

For Production mode,
rake craken:install RAILS_ENV=production

You are done 🙂

More about it……..,
If we need to check the Cronjob, you can give the following command,

crontab -l

Following command displays the log once CRON job executes
tail -f /var/log/syslog

Ref URL – http://github.com/latimes/craken

Advertisements

Posted in Useful Links | 2 Comments »