Spawning in Rails
-
23-09-2019 - |
Question
I was using the spawn plugin (http://rubyforge.org/projects/spawn/) which worked excellent. However, I then moved to Mongo (using mongo_mapper) and Spawn no longer worked.
Modifying the plugin is beyond the scope of my abilities. Is there a simple way to do spawning in Rails that would work with Mongo? It's not an often-run process so it doesn't have to be the most elegant solution in the world.
Thanks!
Solution
It looks like the reason it's not working is because:
The plugin also patches ActiveRecord::Base to handle some known bugs when using
threads (see lib/patches.rb).
Is there anyway you could use a cron job with script/runner
? If so the following link should help you:
http://www.ameravant.com/posts/recurring-tasks-in-ruby-on-rails-using-runner-and-cron-jobs
OTHER TIPS
I am a big fan of putting the logic into a controller and using cron to call the page with curl or wget.
Easy, cheap, works within the Rails stack so you can re-use your code.