Jacob <[email protected]> wrote:
> I know that Unicorn opens and shares it's bound socket amongst its
> sub-processes, however I was hoping I could also pre-open a socket to
> be handed off to Unicorn.
Yes, but unicorn has this feature to support in-place upgrades
(SIGUSR2). You still need to tell unicorn about the socket via config
file or command-line, otherwise it'll close sockets it does not know
about (to support changing addresses/ports during USR2 upgrades).
You need to set the UNICORN_FD environment variable in the parent
Something like this (untested):
require "socket"
# bind the socket in the parent
s = TCPServer.new("0.0.0.0", 1234)
# this may be comma-delimited list of FD numbers:
ENV["UNICORN_FD"] = s.fileno.to_s
# sharing non-standard FDs over exec() must be explicit in Ruby 2.0:
s.close_on_exec = false
redirects = { s => s }
# unicorn must know about the bound address of the FDs its inheriting
exec("unicorn", "-l", "0.0.0.0:1234", redirects)
_______________________________________________
Unicorn mailing list - [email protected]
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying