Technological journey's of a lonely African Programmer
In: Ruby on Rails
2 Jan 2010I 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.
Just tackling programming nightmares with flares. Sometimes the tactics are smooth sometimes their rough.