I am using Resque to run a background process. This is how my background process works:
- Scans through all the rows in an ActiveRecord model
- Checks for a condition
- Updates the row if the condition is met
And this needs to go on infinitely.
This is how I am trying to use Resque for my purpose, here's my worker class:
class ThumbnailMaker
@queue = :thumbnail_queue
def self.perform()
MyObj.check_thumbnails(root_url)
end
end
I understand the perform()
method keeps a task in a queue, which is run periodically. In my case, I need a task that scans the whole table, so it runs for a longer time. Is it a good solution to my requirements?
On another note, I need the root url for my Rails application, which is easily obtained with the root_url
in Rails Controller. But I need it in a class I have created, can you suggest me how I can get it here?