From 56267474dac278898bf2f53b9a43fb68bd83f43d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 4 Dec 2006 03:50:57 +0000 Subject: Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5672 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/CHANGELOG | 2 ++ railties/lib/commands/process/spawner.rb | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index b8b23352d1..3491c0c336 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [DHH] + * Added one-letter aliases for the three default environments to script/console, so script/console p will load the production environment (t for test, d for development) [DHH] * Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH] diff --git a/railties/lib/commands/process/spawner.rb b/railties/lib/commands/process/spawner.rb index 43d652b4e5..c8ca1d04a2 100644 --- a/railties/lib/commands/process/spawner.rb +++ b/railties/lib/commands/process/spawner.rb @@ -56,11 +56,18 @@ end class MongrelSpawner < Spawner def self.spawn(port) - cmd = "mongrel_rails start -d -p #{port} -P #{OPTIONS[:pids]}/#{OPTIONS[:process]}.#{port}.pid -e #{OPTIONS[:environment]}" - cmd << "-a #{OPTIONS[:address]}" if can_bind_to_custom_address? + cmd = + "mongrel_rails start -d " + + "-a #{OPTIONS[:address]} " + + "-p #{port} " + + "-P #{OPTIONS[:pids]}/#{OPTIONS[:process]}.#{port}.pid " + + "-e #{OPTIONS[:environment]} " + + "-c #{OPTIONS[:rails_root]} " + + "-l #{OPTIONS[:rails_root]}/log/mongrel.log" + system(cmd) end - + def self.can_bind_to_custom_address? true end @@ -109,6 +116,7 @@ OPTIONS = { :spawner => '/usr/bin/env spawn-fcgi', :dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi'), :pids => File.expand_path(RAILS_ROOT + "/tmp/pids"), + :rails_root => File.expand_path(RAILS_ROOT), :process => "dispatch", :port => 8000, :address => '0.0.0.0', @@ -165,9 +173,11 @@ ARGV.options do |opts| opts.on(" Options:") opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| } + if spawner_class.can_bind_to_custom_address? opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |OPTIONS[:address]| } end + opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v } opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})") { |v| OPTIONS[:instances] = v } opts.on("-r", "--repeat=seconds", Integer, "Repeat spawn attempts every n seconds (default: off)") { |v| OPTIONS[:repeat] = v } @@ -196,4 +206,4 @@ if OPTIONS[:repeat] end else spawner_class.spawn_all -end +end \ No newline at end of file -- cgit v1.2.3