Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed script/process/spawner to work properly with Mongrel including …

…in -r (daemonize mode) [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5672 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit bd261ffd1f45e308b635bd0482afb6d038d7b568 1 parent ffb17e8
@dhh dhh authored
Showing with 16 additions and 4 deletions.
  1. +2 −0  railties/CHANGELOG
  2. +14 −4 railties/lib/commands/process/spawner.rb
View
2  railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [DHH]
+
* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [DHH]
* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH]
View
18 railties/lib/commands/process/spawner.rb
@@ -56,11 +56,18 @@ def self.can_bind_to_custom_address?
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 @@ def self.can_bind_to_custom_address?
: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 @@ def self.can_bind_to_custom_address?
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 @@ def self.can_bind_to_custom_address?
end
else
spawner_class.spawn_all
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.