Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
memory reductions in worker process
There's absolutely no need to keep the OptionParser around in
worker processes.
  • Loading branch information
Eric Wong committed Jun 15, 2011
1 parent e9e7a1c commit 4beeb52
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/unicorn
Expand Up @@ -106,6 +106,7 @@ op = OptionParser.new("", 24, ' ') do |opts|
end end


app = Unicorn.builder(ARGV[0] || 'config.ru', op) app = Unicorn.builder(ARGV[0] || 'config.ru', op)
op = nil


if $DEBUG if $DEBUG
require 'pp' require 'pp'
Expand Down
1 change: 1 addition & 0 deletions bin/unicorn_rails
Expand Up @@ -186,6 +186,7 @@ def rails_builder(ru, op, daemonize)
end end


app = rails_builder(ARGV[0], op, rackup_opts[:daemonize]) app = rails_builder(ARGV[0], op, rackup_opts[:daemonize])
op = nil


if $DEBUG if $DEBUG
require 'pp' require 'pp'
Expand Down
4 changes: 2 additions & 2 deletions lib/unicorn.rb
Expand Up @@ -31,9 +31,9 @@ class ClientShutdown < EOFError
# app (which we defer based on the outcome of "preload_app" in the # app (which we defer based on the outcome of "preload_app" in the
# Unicorn config). The returned lambda will be called when it is # Unicorn config). The returned lambda will be called when it is
# time to build the app. # time to build the app.
def self.builder(ru, opts) def self.builder(ru, op)
# allow Configurator to parse cli switches embedded in the ru file # allow Configurator to parse cli switches embedded in the ru file
Unicorn::Configurator::RACKUP.update(:file => ru, :optparse => opts) op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op)


# always called after config file parsing, may be called after forking # always called after config file parsing, may be called after forking
lambda do || lambda do ||
Expand Down
4 changes: 3 additions & 1 deletion lib/unicorn/http_server.rb
Expand Up @@ -458,7 +458,9 @@ def murder_lazy_workers


def after_fork_internal def after_fork_internal
@ready_pipe.close if @ready_pipe @ready_pipe.close if @ready_pipe
@ready_pipe = nil Unicorn::Configurator::RACKUP.clear
@ready_pipe = @init_listeners = @config = @before_exec = @before_fork = nil

srand # http://redmine.ruby-lang.org/issues/4338 srand # http://redmine.ruby-lang.org/issues/4338


# The OpenSSL PRNG is seeded with only the pid, and apps with frequently # The OpenSSL PRNG is seeded with only the pid, and apps with frequently
Expand Down

0 comments on commit 4beeb52

Please sign in to comment.