about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-08-30 07:59:01 +0000
committerEric Wong <normalperson@yhbt.net>2010-08-30 08:06:10 +0000
commit0aaa0afa49a2953b7c26c1596a284621e23d5fc4 (patch)
tree8505c3d7e9cdf516739e2bc51648b1219e8beb38 /bin
parentf3e1653b900596e054297675becd01d9985ad482 (diff)
downloadunicorn-0aaa0afa49a2953b7c26c1596a284621e23d5fc4.tar.gz
These nasty hacks were breaking Rubinius compatibility.
This can be further cleaned up, too.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/unicorn22
-rwxr-xr-xbin/unicorn_rails26
2 files changed, 21 insertions, 27 deletions
diff --git a/bin/unicorn b/bin/unicorn
index 8d984bd..73bff3a 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -4,16 +4,13 @@ require 'unicorn/launcher'
 require 'optparse'
 
 ENV["RACK_ENV"] ||= "development"
-daemonize = false
-options = { :listeners => [] }
-host, port = Unicorn::Const::DEFAULT_HOST, Unicorn::Const::DEFAULT_PORT
-set_listener = false
+rackup_opts = Unicorn::Configurator::RACKUP
+options = rackup_opts[:options]
 
 opts = OptionParser.new("", 24, '  ') do |opts|
   cmd = File.basename($0)
   opts.banner = "Usage: #{cmd} " \
                 "[ruby options] [#{cmd} options] [rackup config file]"
-
   opts.separator "Ruby options:"
 
   lineno = 1
@@ -46,14 +43,14 @@ opts = OptionParser.new("", 24, '  ') do |opts|
 
   opts.on("-o", "--host HOST",
           "listen on HOST (default: #{Unicorn::Const::DEFAULT_HOST})") do |h|
-    host = h
-    set_listener = true
+    rackup_opts[:host] = h
+    rackup_opts[:set_listener] = true
   end
 
   opts.on("-p", "--port PORT",
           "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |p|
-    port = p.to_i
-    set_listener = true
+    rackup_opts[:port] = p.to_i
+    rackup_opts[:set_listener] = true
   end
 
   opts.on("-E", "--env ENVIRONMENT",
@@ -62,7 +59,7 @@ opts = OptionParser.new("", 24, '  ') do |opts|
   end
 
   opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
-    daemonize = d ? true : false
+    rackup_opts[:daemonize] = !!d
   end
 
   opts.on("-P", "--pid FILE", "DEPRECATED") do |f|
@@ -109,16 +106,15 @@ opts = OptionParser.new("", 24, '  ') do |opts|
 end
 
 app = Unicorn.builder(ARGV[0] || 'config.ru', opts)
-options[:listeners] << "#{host}:#{port}" if set_listener
 
 if $DEBUG
   require 'pp'
   pp({
     :unicorn_options => options,
     :app => app,
-    :daemonize => daemonize,
+    :daemonize => rackup_opts[:daemonize],
   })
 end
 
-Unicorn::Launcher.daemonize!(options) if daemonize
+Unicorn::Launcher.daemonize!(options) if rackup_opts[:daemonize]
 Unicorn.run(app, options)
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index 0b2d92f..0294b59 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -4,11 +4,9 @@ require 'unicorn/launcher'
 require 'optparse'
 require 'fileutils'
 
-daemonize = false
-options = { :listeners => [] }
-host, port = Unicorn::Const::DEFAULT_HOST, Unicorn::Const::DEFAULT_PORT
-set_listener = false
 ENV['RAILS_ENV'] ||= "development"
+rackup_opts = Unicorn::Configurator::RACKUP
+options = rackup_opts[:options]
 
 opts = OptionParser.new("", 24, '  ') do |opts|
   cmd = File.basename($0)
@@ -46,13 +44,14 @@ opts = OptionParser.new("", 24, '  ') do |opts|
 
   opts.on("-o", "--host HOST",
           "listen on HOST (default: #{Unicorn::Const::DEFAULT_HOST})") do |h|
-    host = h
-    set_listener = true
+    rackup_opts[:host] = h
+    rackup_opts[:set_listener] = true
   end
 
-  opts.on("-p", "--port PORT", "use PORT (default: #{port})") do |p|
-    port = p.to_i
-    set_listener = true
+  opts.on("-p", "--port PORT",
+          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |p|
+    rackup_opts[:port] = p.to_i
+    rackup_opts[:set_listener] = true
   end
 
   opts.on("-E", "--env RAILS_ENV",
@@ -61,7 +60,7 @@ opts = OptionParser.new("", 24, '  ') do |opts|
   end
 
   opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
-    daemonize = d ? true : false
+    rackup_opts[:daemonize] = !!d
   end
 
   # Unicorn-specific stuff
@@ -186,15 +185,14 @@ def rails_builder(ru, opts, daemonize)
   end
 end
 
-app = rails_builder(ARGV[0], opts, daemonize)
-options[:listeners] << "#{host}:#{port}" if set_listener
+app = rails_builder(ARGV[0], opts, rackup_opts[:daemonize])
 
 if $DEBUG
   require 'pp'
   pp({
     :unicorn_options => options,
     :app => app,
-    :daemonize => daemonize,
+    :daemonize => rackup_opts[:daemonize],
   })
 end
 
@@ -203,7 +201,7 @@ options[:after_reload] = lambda do
   FileUtils.mkdir_p(%w(cache pids sessions sockets).map! { |d| "tmp/#{d}" })
 end
 
-if daemonize
+if rackup_opts[:daemonize]
   options[:pid] = "tmp/pids/unicorn.pid"
   Unicorn::Launcher.daemonize!(options)
 end