Forum: Ruby on Rails launch many daemons from script/xxx

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
292e825e3d670ee973e512801e5071a4?d=identicon&s=25 joserwan (Guest)
on 2009-02-02 21:08
(Received via mailing list)
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}
(...)
8b7769e70ec39353842e1730ee991080?d=identicon&s=25 Anton Mironov (Guest)
on 2009-03-19 23:24
(Received via mailing list)
You can use Daemons.call instead of run.
This topic is locked and can not be replied to.