From 0aaa0afa49a2953b7c26c1596a284621e23d5fc4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 30 Aug 2010 07:59:01 +0000 Subject: remove nasty ugly hacks at startup These nasty hacks were breaking Rubinius compatibility. This can be further cleaned up, too. --- bin/unicorn | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'bin/unicorn') 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) -- cgit v1.2.3-24-ge0c7