diff options
-rw-r--r--[-rwxr-xr-x] | railties/lib/commands/process/reaper.rb (renamed from railties/bin/process/reaper) | 40 | ||||
-rw-r--r--[-rwxr-xr-x] | railties/lib/commands/process/spawner.rb (renamed from railties/bin/process/spawner) | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | railties/lib/commands/process/spinner.rb (renamed from railties/bin/process/spinner) | 2 |
3 files changed, 10 insertions, 36 deletions
diff --git a/railties/bin/process/reaper b/railties/lib/commands/process/reaper.rb index 0ab5bbbb8a..27c05ed5ce 100755..100644 --- a/railties/bin/process/reaper +++ b/railties/lib/commands/process/reaper.rb @@ -1,21 +1,7 @@ -#!/usr/local/bin/ruby - require 'optparse' require 'net/http' require 'uri' -def nudge(url, iterations) - print "Nudging #{url}: " - - iterations.times do - Net::HTTP.get_response(URI.parse(url)) rescue nil - print "." - STDOUT.flush - end - - puts -end - if RUBY_PLATFORM =~ /mswin32/ then abort("Reaper is only for Unix") end class ProgramProcess @@ -35,7 +21,7 @@ class ProgramProcess def find_by_keyword(keyword) process_lines_with_keyword(keyword).split("\n").collect { |line| - next if line.include?("inq") || line.include?("ps -wwax") || line.include?("grep") + next if line.include?("inq") || line.include?("ps -ax") || line.include?("grep") pid, *command = line.split new(pid, command.join(" ")) }.compact @@ -43,7 +29,7 @@ class ProgramProcess private def process_lines_with_keyword(keyword) - `ps -wwax -o 'pid command' | grep #{keyword}` + `ps -ax -o 'pid command' | grep #{keyword}` end end @@ -70,18 +56,18 @@ class ProgramProcess `kill -s USR1 #{@pid}` end + def restart + `kill -s USR2 #{@pid}` + end + def to_s "[#{@pid}] #{@command}" end end OPTIONS = { - :action => "graceful", - :dispatcher => File.expand_path(File.dirname(__FILE__) + '/../../public/dispatch.fcgi'), - :spinner => File.expand_path(File.dirname(__FILE__) + '/spinner'), - :toggle_spin => true, - :iterations => 10, - :nudge => false + :action => "restart", + :dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi') } ARGV.options do |opts| @@ -112,17 +98,12 @@ ARGV.options do |opts| Examples: reaper -a reload - reaper -n http://www.example.com -i 10 # gracefully exit, nudge 10 times EOF opts.on(" Options:") opts.on("-a", "--action=name", "reload|graceful|kill (default: #{OPTIONS[:action]})", String) { |OPTIONS[:action]| } opts.on("-d", "--dispatcher=path", "default: #{OPTIONS[:dispatcher]}", String) { |OPTIONS[:dispatcher]| } - opts.on("-s", "--spinner=path", "default: #{OPTIONS[:spinner]}", String) { |OPTIONS[:spinner]| } - opts.on("-t", "--[no-]toggle-spin", "Whether to send a USR1 to the spinner before and after the reaping (default: true)") { |OPTIONS[:toggle_spin]| } - opts.on("-n", "--nudge=url", "Should point to URL that's handled by the FCGI process", String) { |OPTIONS[:nudge]| } - opts.on("-i", "--iterations=number", "One nudge per FCGI process running (default: #{OPTIONS[:iterations]})", Integer) { |OPTIONS[:iterations]| } opts.separator "" @@ -131,7 +112,4 @@ ARGV.options do |opts| opts.parse! end -ProgramProcess.process_keywords("usr1", OPTIONS[:spinner]) if OPTIONS[:toggle_spin] -ProgramProcess.process_keywords(OPTIONS[:action], OPTIONS[:dispatcher]) -nudge(OPTIONS[:nudge], OPTIONS[:iterations]) if OPTIONS[:nudge] -ProgramProcess.process_keywords("usr1", OPTIONS[:spinner]) if OPTIONS[:toggle_spin] +ProgramProcess.process_keywords(OPTIONS[:action], OPTIONS[:dispatcher])
\ No newline at end of file diff --git a/railties/bin/process/spawner b/railties/lib/commands/process/spawner.rb index 2ac0df04f8..465017d8a4 100755..100644 --- a/railties/bin/process/spawner +++ b/railties/lib/commands/process/spawner.rb @@ -1,5 +1,3 @@ -#!/usr/local/bin/ruby - require 'optparse' def spawn(port) @@ -10,7 +8,7 @@ end OPTIONS = { :environment => "production", :spawner => '/usr/bin/env spawn-fcgi', - :dispatcher => File.expand_path(File.dirname(__FILE__) + '/../../public/dispatch.fcgi'), + :dispatcher => File.expand_path(RAILS_ROOT + '/public/dispatch.fcgi'), :port => 8000, :instances => 3 } diff --git a/railties/bin/process/spinner b/railties/lib/commands/process/spinner.rb index f4cd33cac1..88c8e7cbd0 100755..100644 --- a/railties/bin/process/spinner +++ b/railties/lib/commands/process/spinner.rb @@ -1,5 +1,3 @@ -#!/usr/local/bin/ruby - require 'optparse' def daemonize |