Skip to main content

Posts

Showing posts from February, 2011

Deals You Can't Miss

1 Year Subscription

No more cron jobs. Schedule jobs through rufus-scheduler in rails.

In the project that I'm working currently, I was asked to look out for ways to replace the scheduling jobs through crontab in favour of some scheduler that can control/schedule run the tasks at regular interval as long as the application is up and running. Thanks to my comrade in Dev-Ops team (Ranjib Dey) who  directing my attention to rufus-scheduler. rufus-scheduler - Things can't be simpler! Let us see how simple it is in action with a sample code  First step to usage is install the gem; so, find below the command for the same. You run it from the root of your application folder and I assume that you use rvm (if not, prefix the command with - sudo ) > gem install rufus-scheduler Now, when the rails application gets kick-started, it reads all .rb files under config/initializers directory as part of its initialization process. This step in rails start-up, is what we'll take advantage of. So, let us create a new file, say my_tasks_scheduler.rb , in config/initial

Externalizing ALL application specific configurations to a file outside of Rails ROOT

It has been quite a while since I wanted to externalize all application specific configurations to a file outside of Rails ROOT, so that when my application is deployed in production, it picks up the configurations from a file in some specific location outside of Rails environment. The sysadmin makes changes to this file as is required and he alone knows or is eligible to know all these configuration details and certainly not the development team. The application that I'm having in my mind is an internal rails application that gets deployed in an internal hosting environment instead of hosting it in a external environment like Heroku, etc. Follow through the self-explanatory code snippets to get an understanding of how I achieve it in simple way. For the noobs, the quick explanation would be that the code snippet in environment.rb file reads the YAML file from system to copy all key value pairs to Rails' ENV hash. This ENV hash is available everywhere while/on/after appl