views:

220

answers:

2
+1  Q: 

Spawning in Rails

Hello,

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!

A: 

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

jonnii
Yes, maybe you're right that this is the way to go - I'll try cron. Thanks to both of you.
thekevinscott
A: 

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.

Toby Hede