Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created September 22, 2009 18:39
Show Gist options
  • Save defunkt/191309 to your computer and use it in GitHub Desktop.
Save defunkt/191309 to your computer and use it in GitHub Desktop.
after_fork do |server, worker|
##
# Set the listening HTTP port for each of the workers dynamically
port = 5000 + worker.nr
begin
server.listen("127.0.0.1:#{port}")
rescue Errno::EADDRINUSE
# we couldn't grab the port we want so just keep
# trying until someone kills us
sleep 3
retry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment