launch many daemons from script/xxx

Hello, I try to launch many daemons from a script written in the script/repository.

One daemon is launched per site (AR model "Site"). I want to load Rails environment just once.

Each time a daemon is launched, script exits. I tried to "encapsulate" daemon launching in threads, but I have the same issue.

Have you any idea how to do what I want to ?

my codes :

without threading :

(...) Site.all.each{|site|         p "start #{site.name}..."         Daemons.run("#{RAILS_ROOT}/app/daemons/proxy_client.rb", options.merge({:app_name => "proxy_client_# {site.id.to_s}", :ARGV =>[ARGV[0], '--', "SITE=# {site.id.to_s}"]}) } (...)

With threading : (...) Site.all.each{|site|         p "start #{site.name}..."         @threads << Thread.new{Daemons.run("#{RAILS_ROOT}/app/daemons/ proxy_client.rb", options.merge({:app_name => "proxy_client_# {site.id.to_s}",                                                :ARGV =>[ARGV[0], '--', "SITE=#{site.id.to_s}"]}))                              }       end @threads.each{|t| t.join} (...)

You can use Daemons.call instead of run.