aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/Rakefile2
-rw-r--r--railties/bin/process/spinner3
-rw-r--r--railties/lib/commands/process/spawner.rb25
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb2
5 files changed, 26 insertions, 8 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index fab2a5c383..c2385b468f 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added -r/--repeat option to script/process/spawner that offers the same loop protection as the spinner did. This deprecates the script/process/spinner, so it's no longer included in the default Rails skeleton, but still available for backwards compatibility #3461 [ror@andreas-s.net]
+
* Added collision option to template generation in generators #3329 [anna@wota.jp]. Examples:
m.template "stuff.config" , "config/stuff.config" , :collision => :skip
diff --git a/railties/Rakefile b/railties/Rakefile
index 21cdd375c4..60ee244083 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -41,7 +41,7 @@ LOG_FILES = %w( server.log development.log test.log production.log )
HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico images/rails.png
javascripts/prototype.js
javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
-BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin )
+BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner runner server plugin )
VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
diff --git a/railties/bin/process/spinner b/railties/bin/process/spinner
deleted file mode 100644
index 6816b32ef4..0000000000
--- a/railties/bin/process/spinner
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/process/spinner'
diff --git a/railties/lib/commands/process/spawner.rb b/railties/lib/commands/process/spawner.rb
index 465017d8a4..031beb4c15 100644
--- a/railties/lib/commands/process/spawner.rb
+++ b/railties/lib/commands/process/spawner.rb
@@ -1,16 +1,21 @@
require 'optparse'
def spawn(port)
- print "Starting FCGI on port: #{port}\n "
+ puts "Starting FCGI on port: #{port}"
system("#{OPTIONS[:spawner]} -f #{OPTIONS[:dispatcher]} -p #{port}")
end
+def spawn_all
+ OPTIONS[:instances].times { |i| spawn(OPTIONS[:port] + i) }
+end
+
OPTIONS = {
:environment => "production",
:spawner => '/usr/bin/env spawn-fcgi',
:dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi'),
:port => 8000,
- :instances => 3
+ :instances => 3,
+ :repeat => nil
}
ARGV.options do |opts|
@@ -28,15 +33,20 @@ ARGV.options do |opts|
You decide a starting port (default is 8000) and the number of FCGI process instances you'd
like to run. So if you pick 9100 and 3 instances, you'll start processes on 9100, 9101, and 9102.
+ By setting the repeat option, you get a protection loop, which will attempt to restart any FCGI processes
+ that might have been exited or outright crashed.
+
Examples:
spawner # starts instances on 8000, 8001, and 8002
spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109
+ spawner -p 9100 -r 5 # starts 3 instances counting from 9100 to 9102 and attempts start them every 5 seconds
EOF
opts.on(" Options:")
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})") { |OPTIONS[:instances]| }
+ opts.on("-r", "--repeat=seconds", Integer, "Repeat spawn attempts every n seconds (default: off)") { |OPTIONS[:repeat]| }
opts.on("-e", "--environment=name", String, "test|development|production (default: #{OPTIONS[:environment]})") { |OPTIONS[:environment]| }
opts.on("-s", "--spawner=path", String, "default: #{OPTIONS[:spawner]}") { |OPTIONS[:spawner]| }
opts.on("-d", "--dispatcher=path", String, "default: #{OPTIONS[:dispatcher]}") { |dispatcher| OPTIONS[:dispatcher] = File.expand_path(dispatcher) }
@@ -49,4 +59,13 @@ ARGV.options do |opts|
end
ENV["RAILS_ENV"] = OPTIONS[:environment]
-OPTIONS[:instances].times { |i| spawn(OPTIONS[:port] + i) } \ No newline at end of file
+
+if OPTIONS[:repeat]
+ loop do
+ spawn_all
+ puts "Sleeping for #{OPTIONS[:repeat]} seconds"
+ sleep OPTIONS[:repeat]
+ end
+else
+ spawn_all
+end
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index b421c5df74..f6544e7ced 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -47,7 +47,7 @@ class AppGenerator < Rails::Generator::Base
m.file "environments/test.rb", "config/environments/test.rb"
# Scripts
- %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin ).each do |file|
+ %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner runner server plugin ).each do |file|
m.file "bin/#{file}", "script/#{file}", script_options
end