views:

72

answers:

1

I tried to make a script that would execute several external binaries to perform some tasks. Each binary was executed from a different thread, but the thing is, it didn't work ( because of the implementation of Ruby's threads in 1.8.6 ).

Is there a different way I could do this, or do I have to go with Ruby 1.9 ?

+2  A: 

Have you try Ruby Daemons? I have about 15 external application running simultaneously with RoR by implement it. (http://daemons.rubyforge.org/)

Basically, you extract your thread code to another ruby file. say my_external_call.rb. then, create a daemon control

require 'daemons'

Daemons.run('my_external_call.rb')

execute it by 'ruby control.rb start | stop | status'

Jirapong
I think this would be a bad solution, because then I would have to poll the daemons for data. I need to process the output produced by the binaries.
Geo
You can use IO.popen("your exe").read() to get all STDOUT that produced, as well as input. see this link http://whynotwiki.com/Ruby_/_Process_management
Jirapong