diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 19:21:54 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 19:21:54 +0000 |
commit | 8bf987140a40a523a34bb6a52dd23afb99f92331 (patch) | |
tree | 190b01112e851c8f25e3f1ac058aed6bef5085eb /railties/lib/commands | |
parent | 3dc7f7603785c1173df5c24f8b76323f7a795443 (diff) | |
download | rails-8bf987140a40a523a34bb6a52dd23afb99f92331.tar.gz rails-8bf987140a40a523a34bb6a52dd23afb99f92331.tar.bz2 rails-8bf987140a40a523a34bb6a52dd23afb99f92331.zip |
Added 'port open?' check to the spawner when running in repeat mode so we don't needlessly boot the dispatcher if the port is already in use anyway #4089 [guy.naor@famundo.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3938 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/commands')
-rw-r--r-- | railties/lib/commands/process/spawner.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/railties/lib/commands/process/spawner.rb b/railties/lib/commands/process/spawner.rb index 031beb4c15..47259979d6 100644 --- a/railties/lib/commands/process/spawner.rb +++ b/railties/lib/commands/process/spawner.rb @@ -1,10 +1,20 @@ require 'optparse' +require 'socket' def spawn(port) - puts "Starting FCGI on port: #{port}" - system("#{OPTIONS[:spawner]} -f #{OPTIONS[:dispatcher]} -p #{port}") + print "Checking if something is already running on port #{port}..." + begin + srv = TCPServer.new('0.0.0.0', port) + srv.close + srv = nil + print "NO\n " + print "Starting FCGI on port: #{port}\n " + system("#{OPTIONS[:spawner]} -f #{OPTIONS[:dispatcher]} -p #{port}") + rescue + print "YES\n" + end end - + def spawn_all OPTIONS[:instances].times { |i| spawn(OPTIONS[:port] + i) } end |