Heavy weight Rails Job workaround

In: Ruby on Rails

2 Jan 2010

I am working on a Rails project and I recently had to do some FTP tricky stuff. I had to allow users to upload audio Files which will be transferred via FTP to another Server for processing to voice sms. Now its easy to do this on a lightly used system with a small audio file size and a very fast internet connection. The annoying part is waiting for all the process to complete in one single shot, uuh!

So I had to split it up, make the user upload the file and then a background process handles the rest of the work. That when I came across DELAYED_JOB created by Tobias Lütke (Tobi), I think its an awesome gem and saves you from a lot of work and making you concentrate on other important stuffs. I handled renaming of the audio file, FTP jobs, and user notification on the job status via email all through the background process. Changing your current code to be background processed is too easy here.

OLD CODE

AudioFile.start_process @voice_campaign.id

NEW CODE

AudioFile.send_later :start_process, @voice_campaign.id

Then there was a second problem, setting up the application on the production server in a way that delayed_job will automatically start even after a system reboot, uuuuh! That was when GOD (Monitoring Framework in Ruby) came to the rescue. Modified few things to suite my production server and BAM!! Everything started to workout like charm.

Comment Form

About this blog

Just tackling programming nightmares with flares. Sometimes the tactics are smooth sometimes their rough.

Photostream

About Me

1Alfred is a seasoned programmer with over 8 years of experience, CEO of nCodedev Labs, a Ruby evangelist and activist. Loves programming most of the time, spends my free times with his family or trying out something new. He believes in doing more than expected of you and working hard at anything you find your self working on. As he always says, you don't have to take the bull by its horns all the time, you can take it by the tail too and move on to the horns when you stronger.