Re: How to trap USR2 for custom ussage ?

2009-12-24 Thread Iñaki Baz Castillo
El Miércoles, 23 de Diciembre de 2009, Eric Wong escribió:

 First off I really don't think you need to be using DRb for this or
 (generally) sticking things into the master process that don't belong
 there.

The problem is: how to start a server (which binds in a TCP port) in just one 
worker? humm, would the following make sense?:

  after_fork do |server, worker|
# Start DRb server just in worker[0]
if worker.nr == 0
  ... start DRb server ...
end
  end

But it would also fail upon receipt of USR2 as there would be two instances of 
the DRb server trying to bind on same port...


  Is there any way to achive this?
  I could imagine a new config option on_usr2 (or before_reexec) so the
  passsed block would be executed upon receipt of USR2 (before the real
  reexec method).
 
  Does it make sense?
 
 There's already a similar before_exec hook documented in
 http://unicorn.bogomips.org/Unicorn/Configurator.html
 But it is called after forking, so the listener will be shared.

Hummm, perhaps I could use the above code plus:

  before_exec do |server|
 stop DRb server ...
  end

In this way the DRb server is stopped before exec and started in the new 
worker[0].
Just a problem, how to access to existing/old worker[0] from before_exec in 
order to stop the DRb server?


 
 But again, you don't need to use DRb for this.

As I've said in other thread I want DRb to get some info related to the 
application. A DRb client console could be used to check application 
database(s) connection and so.
What would you suggest for this rather than DRb server?

 
Again thanks a lot for your help.


-- 
Iñaki Baz Castillo i...@aliax.net
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


Re: How to trap USR2 for custom ussage ?

2009-12-24 Thread Eric Wong
Iñaki Baz Castillo i...@aliax.net wrote:
 El Miércoles, 23 de Diciembre de 2009, Eric Wong escribió:
  But again, you don't need to use DRb for this.
 
 As I've said in other thread I want DRb to get some info related to the 
 application. A DRb client console could be used to check application 
 database(s) connection and so.
 What would you suggest for this rather than DRb server?

As I said before, write an endpoint in your HTTP application that
calls and displays all the needed info you need.  Something that
hits the database(s) and/or whatever else you're using.

There's no need to introduce another socket protocol into that process.

-- 
Eric Wong
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying