Hey All, I''m setting up some mongrel servers.. can''t get it to daemonize. here is my configurator block:: config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) end run.join if OPTIONS[:daemon] daemonize end end Any ideas? Also I was looking in the mongrel source and see that in the daemonize method your calling Daemon.daemonize. Is that depending on some library? I don''t see it anywhere in the ruby docs. I did find this: http://grub.ath.cx/daemonize/ and install it but that didn''t seem to help. thanks Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070626/b7d2099d/attachment.html
On Jun 26, 2007, at 4:01 PM, aaron smith wrote:> Hey All, > > I''m setting up some mongrel servers.. can''t get it to daemonize. > > here is my configurator block:: > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > #debug(''/gateway.rb'',[:access,:threads]) > listener :port => OPTIONS[:port] do > uri("/gateway.rb", :handler => > RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) > end > run.join > if OPTIONS[:daemon] > daemonize > end > end > > Any ideas? Also I was looking in the mongrel source and see that in > the daemonize method your calling Daemon.daemonize. Is that > depending on some library? I don''t see it anywhere in the ruby > docs. I did find this: http://grub.ath.cx/daemonize/ and install > it but that didn''t seem to help. > > thanks > Aaron >config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) end if OPTIONS[:daemon] daemonize end end config.run.join You were doing run.join before you daemonized so the daemoinize code never gets called. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
On 6/26/07, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:> > > On Jun 26, 2007, at 4:01 PM, aaron smith wrote: > > > Hey All, > > > > I''m setting up some mongrel servers.. can''t get it to daemonize. > > > > here is my configurator block:: > > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > #debug(''/gateway.rb'',[:access,:threads]) > > listener :port => OPTIONS[:port] do > > uri("/gateway.rb", :handler => > > RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) > > end > > run.join > > if OPTIONS[:daemon] > > daemonize > > end > > end > > > > Any ideas? Also I was looking in the mongrel source and see that in > > the daemonize method your calling Daemon.daemonize. Is that > > depending on some library? I don''t see it anywhere in the ruby > > docs. I did find this: http://grub.ath.cx/daemonize/ and install > > it but that didn''t seem to help. > > > > thanks > > Aaron > > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > #debug(''/gateway.rb'',[:access,:threads]) > listener :port => OPTIONS[:port] do > uri("/gateway.rb", :handler => > RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) > end > if OPTIONS[:daemon] > daemonize > end > end > > config.run.join > > You were doing run.join before you daemonized so the daemoinize > code > never gets called. > > Cheers- > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez at engineyard.com > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >Thanks that almost got it.. couple more things: here is the new configurator: config = Mongrel::Configurator.new(:host => OPTIONS[:ip], :log_file => ''../../rubyamf_core/logs/mongrel.log'') do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) end end if OPTIONS[:daemon] config.daemonize end config.run.join ----That outputs these errors.. /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in `join'': can''t convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in `daemonize'' Any ideas on that one? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070626/6f661ee5/attachment.html
On 6/26/07, aaron smith <beingthexemplarylists at gmail.com> wrote:> > > On 6/26/07, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote: > > > > > > On Jun 26, 2007, at 4:01 PM, aaron smith wrote: > > > > > Hey All, > > > > > > I''m setting up some mongrel servers.. can''t get it to daemonize. > > > > > > here is my configurator block:: > > > > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > > #debug(''/gateway.rb'',[:access,:threads]) > > > listener :port => OPTIONS[:port] do > > > uri("/gateway.rb", :handler => > > > RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) > > > end > > > run.join > > > if OPTIONS[:daemon] > > > daemonize > > > end > > > end > > > > > > Any ideas? Also I was looking in the mongrel source and see that in > > > the daemonize method your calling Daemon.daemonize. Is that > > > depending on some library? I don''t see it anywhere in the ruby > > > docs. I did find this: http://grub.ath.cx/daemonize/ and install > > > it but that didn''t seem to help. > > > > > > thanks > > > Aaron > > > > > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > #debug(''/gateway.rb'',[:access, :threads]) > > listener :port => OPTIONS[:port] do > > uri("/gateway.rb", :handler => > > RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processors]) > > end > > if OPTIONS[:daemon] > > daemonize > > end > > end > > > > config.run.join > > > > You were doing run.join before you daemonized so the daemoinize > > code > > never gets called. > > > > Cheers- > > -- Ezra Zygmuntowicz > > -- Lead Rails Evangelist > > -- ez at engineyard.com > > -- Engine Yard, Serious Rails Hosting > > -- (866) 518-YARD (9273) > > > > > > _______________________________________________ > > Mongrel-users mailing list > > Mongrel-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > > > Thanks that almost got it.. couple more things: > > > here is the new configurator: > > > config = Mongrel:: Configurator.new(:host => OPTIONS[:ip], :log_file => > ''../../rubyamf_core/logs/mongrel.log'') do > #debug(''/gateway.rb'',[:access,:threads]) > listener :port => OPTIONS[:port] do > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > :num_processors => OPTIONS[:processors]) > end > end > > if OPTIONS[:daemon] > config.daemonize > end > > config.run.join > > ----That outputs these errors.. > > > /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1 > /lib/mongrel/configurator.rb:182:in `join'': can''t convert nil into String > (TypeError) > from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in > `daemonize'' > > > > > Any ideas on that one? >Wait it was because I had set :log_file there.. I took that out now I get these:: /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:181:in `daemonize'': undefined method `[]'' for nil:NilClass (NoMethodError) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070626/4ba72534/attachment.html
Ok here is my latest configurator block.. config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, :num_processors => OPTIONS[:processes]) end end if OPTIONS[:daemon] config.daemonize(:log_file => ''../../rubyamf_core/logs/mongrel.log'') end config.run.join I get one error: usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in `join'': can''t convert nil into String (TypeError) Thanks everyone -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070626/92062b20/attachment-0001.html
On 6/26/07, aaron smith <beingthexemplarylists at gmail.com> wrote:> > Ok here is my latest configurator block.. > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > #debug(''/gateway.rb'',[:access,:threads]) > listener :port => OPTIONS[:port] do > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > :num_processors => OPTIONS[:processes]) > end > end > > if OPTIONS[:daemon] > config.daemonize(:log_file => ''../../rubyamf_core/logs/mongrel.log'') > end > > config.run.join > > > > I get one error: > usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in > `join'': can''t convert nil into String (TypeError) > > > Thanks everyone >Ok I got it daemonizing correctly with this config block config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new) end end if OPTIONS[:daemon] config.daemonize(:cwd => Dir.pwd, :log_file => ''/rubyamf_core/logs/mongrel.log'') end config.run.join Now my question is: why doesn''t it run as expected with its daemonized.. if I run it without being daemonized it''s fine.. but as soon as its daemonized it doesn''t run as expected. Any ideas? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070626/f59c3128/attachment.html
If I read the docs correctly, after you call #daemonize, you can just exit the script. You don''t need the `config.run.join` step. Maybe move that into an else clause after the OPTIONS[:daemon] check. BTW, where did you get RUBYAMF::MongrelServlet? On 6/27/07, aaron smith <beingthexemplarylists at gmail.com> wrote:> > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > #debug(''/gateway.rb'',[:access,:threads]) > > listener :port => OPTIONS[:port] do > > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > :num_processors => OPTIONS[:processes]) > > end > > end > > > > if OPTIONS[:daemon] > > config.daemonize(:log_file => > ''../../rubyamf_core/logs/mongrel.log'') > > end > > > > config.run.join > > > > I get one error: > > > usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:182:in > `join'': can''t convert nil into String (TypeError)
Eden, That is from the rubyamf project: http://rubyamf.org/. It enables Actionscript objects to flow freely from within Ruby to Flash/Flex. The latest version has a Mongrel servlet. Prett cool if you ask me! - Michael On 6/26/07, Eden Li <eden at mojiti.com> wrote:> > If I read the docs correctly, after you call #daemonize, you can just > exit the script. You don''t need the `config.run.join` step. Maybe > move that into an else clause after the OPTIONS[:daemon] check. > > BTW, where did you get RUBYAMF::MongrelServlet? > > On 6/27/07, aaron smith <beingthexemplarylists at gmail.com> wrote: > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > > #debug(''/gateway.rb'',[:access,:threads]) > > > listener :port => OPTIONS[:port] do > > > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > > :num_processors => OPTIONS[:processes]) > > > end > > > end > > > > > > if OPTIONS[:daemon] > > > config.daemonize(:log_file => > > ''../../rubyamf_core/logs/mongrel.log'') > > > end > > > > > > config.run.join > > > > > > I get one error: > > > > > usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1 > /lib/mongrel/configurator.rb:182:in > > `join'': can''t convert nil into String (TypeError) > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070627/d18a0d44/attachment.html
On 6/26/07, Eden Li <eden at mojiti.com> wrote:> > If I read the docs correctly, after you call #daemonize, you can just > exit the script. You don''t need the `config.run.join` step. Maybe > move that into an else clause after the OPTIONS[:daemon] check. > > BTW, where did you get RUBYAMF::MongrelServlet? > > On 6/27/07, aaron smith <beingthexemplarylists at gmail.com> wrote: > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > > #debug(''/gateway.rb'',[:access,:threads]) > > > listener :port => OPTIONS[:port] do > > > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > > :num_processors => OPTIONS[:processes]) > > > end > > > end > > > > > > if OPTIONS[:daemon] > > > config.daemonize(:log_file => > > ''../../rubyamf_core/logs/mongrel.log'') > > > end > > > > > > config.run.join > > > > > > I get one error: > > > > > usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1 > /lib/mongrel/configurator.rb:182:in > > `join'': can''t convert nil into String (TypeError) > _______________________________________________ > > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >Hey Eden config.run.join is actually what keeps it running. if I do a "ps x | grep mongrel" the process shows up.. but if I don''t run config.run.join it doesn''t keep running.. config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do #debug(''/gateway.rb'',[:access,:threads]) listener :port => OPTIONS[:port] do uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new) end end if OPTIONS[:daemon] config.daemonize(:cwd => Dir.pwd, :log_file => ''/rubyamf_core/logs/mongrel.log'') end config.run.join The problem still is that mongrel seems to be daemonizing correctly but the application doesn''t perform as expected, (not doing remoting correctly).. A request comes in and no response is ever returned.. any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070628/8a02f666/attachment.html
On 6/28/07, aaron smith <beingthexemplarylists at gmail.com> wrote:> > > > On 6/26/07, Eden Li <eden at mojiti.com> wrote: > > > > If I read the docs correctly, after you call #daemonize, you can just > > exit the script. You don''t need the `config.run.join` step. Maybe > > move that into an else clause after the OPTIONS[:daemon] check. > > > > BTW, where did you get RUBYAMF::MongrelServlet? > > > > On 6/27/07, aaron smith <beingthexemplarylists at gmail.com> wrote: > > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > > > > #debug(''/gateway.rb'',[:access,:threads]) > > > > listener :port => OPTIONS[:port] do > > > > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new, > > > :num_processors => OPTIONS[:processes]) > > > > end > > > > end > > > > > > > > if OPTIONS[:daemon] > > > > config.daemonize(:log_file => > > > ''../../rubyamf_core/logs/mongrel.log'') > > > > end > > > > > > > > config.run.join > > > > > > > > I get one error: > > > > > > > usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1 > > /lib/mongrel/configurator.rb:182:in > > > `join'': can''t convert nil into String (TypeError) > > ______________________________ _________________ > > > > Mongrel-users mailing list > > Mongrel-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > > > > Hey Eden > > > config.run.join is actually what keeps it running. if I do a "ps x | grep > mongrel" the process shows up.. but if I don''t run config.run.join it > doesn''t keep running.. > > > config = Mongrel::Configurator.new(:host => OPTIONS[:ip]) do > #debug(''/gateway.rb'',[:access,:threads]) > listener :port => OPTIONS[:port] do > uri("/gateway.rb", :handler => RUBYAMF::MongrelServlet.new) > end > end > > if OPTIONS[:daemon] > config.daemonize(:cwd => Dir.pwd, :log_file => > ''/rubyamf_core/logs/mongrel.log'') > end > config.run.join > > > > The problem still is that mongrel seems to be daemonizing correctly but > the application doesn''t perform as expected, (not doing remoting > correctly).. A request comes in and no response is ever returned.. > > any ideas? >I can''t even access the gateway from the browser when it''s a daemon.. ( http://localhost:8024/gateway.rb). I get a 404. . is it something to do with the config? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070628/05d844f0/attachment.html
On 6/29/07, aaron smith <beingthexemplarylists at gmail.com> wrote:> config.run.join is actually what keeps it running. if I do a "ps x | grep > mongrel" the process shows up.. but if I don''t run config.run.join it > doesn''t keep running..Yeah, I guess I misunderstood how Daemon.daemonize works, sorry about that.> The problem still is that mongrel seems to be daemonizing correctly but > the application doesn''t perform as expected, (not doing remoting > correctly).. A request comes in and no response is ever returned.. > > any ideas?I wrote a little test script that daemonizes DirHandler in the same way you''re daemonizing RUBYAMF::MongrelServlet: #!/usr/bin/env ruby require ''rubygems'' require ''mongrel'' c = Mongrel::Configurator.new(:host => ''127.0.0.1'') do listener(:port => 8000) do uri("/", :handler => Mongrel::DirHandler.new(''.'')) end end c.daemonize(:cwd => Dir.pwd, :log_file => ''log'') c.run.join This daemonizes correctly, but the log file bloats quickly with messages like: !!!!!! UNHANDLED EXCEPTION! closed stream. TELL ZED HE''S A MORON. Going back to the docs for daemonize, I read: "You must call this before frameworks that open files as otherwise the files will be closed by this function." So I put the daemonize line into the config block right before the listener block (removing the ref to c, of course), and everything works as expected. Maybe try daemonizing before you initialize your RUBYAMF handler?
On 6/29/07, Eden Li <eden at mojiti.com> wrote:> > On 6/29/07, aaron smith <beingthexemplarylists at gmail.com> wrote: > > config.run.join is actually what keeps it running. if I do a "ps x | > grep > > mongrel" the process shows up.. but if I don''t run config.run.join it > > doesn''t keep running.. > > Yeah, I guess I misunderstood how Daemon.daemonize works, sorry about > that. > > > The problem still is that mongrel seems to be daemonizing correctly but > > the application doesn''t perform as expected, (not doing remoting > > correctly).. A request comes in and no response is ever returned.. > > > > any ideas? > > I wrote a little test script that daemonizes DirHandler in the same > way you''re daemonizing RUBYAMF::MongrelServlet: > > #!/usr/bin/env ruby > require ''rubygems'' > require ''mongrel'' > c = Mongrel::Configurator.new(:host => ''127.0.0.1'') do > listener(:port => 8000) do > uri("/", :handler => Mongrel::DirHandler.new(''.'')) > end > end > c.daemonize(:cwd => Dir.pwd, :log_file => ''log'') > c.run.join > > This daemonizes correctly, but the log file bloats quickly with messages > like: > !!!!!! UNHANDLED EXCEPTION! closed stream. TELL ZED HE''S A MORON. > > Going back to the docs for daemonize, I read: > > "You must call this before frameworks that open files as otherwise the > files will be closed by this function." > > So I put the daemonize line into the config block right before the > listener block (removing the ref to c, of course), and everything > works as expected. > > Maybe try daemonizing before you initialize your RUBYAMF handler? > _______________________________________________ > > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >AHH. that''s what it was. I even read that in the docs it just didn''t click in my head. Thanks much!!!!!! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070629/4a8de998/attachment.html