aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin/process/reaper
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-26 12:39:44 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-26 12:39:44 +0000
commit5b8b9178b357b46af2d8ff638b0ceac78e709a9e (patch)
tree0289e92fc7edf331ac37486221c90069bf285a57 /railties/bin/process/reaper
parent65e4e5e337a4ec043411879931081e310145e293 (diff)
downloadrails-5b8b9178b357b46af2d8ff638b0ceac78e709a9e.tar.gz
rails-5b8b9178b357b46af2d8ff638b0ceac78e709a9e.tar.bz2
rails-5b8b9178b357b46af2d8ff638b0ceac78e709a9e.zip
Made the reaper talk to the spinner to make it spin faster during restarts and slower afterwards
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1931 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/bin/process/reaper')
-rwxr-xr-xrailties/bin/process/reaper24
1 files changed, 16 insertions, 8 deletions
diff --git a/railties/bin/process/reaper b/railties/bin/process/reaper
index a636d329c8..3b58698653 100755
--- a/railties/bin/process/reaper
+++ b/railties/bin/process/reaper
@@ -60,16 +60,22 @@ class ProgramProcess
`kill -9 #{@pid}`
end
+ def usr1
+ `kill -s USR1 #{@pid}`
+ end
+
def to_s
"[#{@pid}] #{@command}"
end
end
OPTIONS = {
- :action => "graceful",
- :dispatcher => File.expand_path(File.dirname(__FILE__) + '/../../public/dispatch.fcgi'),
- :iterations => 10,
- :nudge => false
+ :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
}
ARGV.options do |opts|
@@ -97,9 +103,7 @@ ARGV.options do |opts|
FCGI process you have running if they're setup in a round-robin. Be sure to do one nudge per FCGI process
across all your servers. So three servers with 10 processes each should nudge 30 times to be sure all processes
are restarted.
-
- NOTE: You're responsible for restarting the processes after they exit. This can be automated by using
- the spinner.
+
Examples:
reaper -a reload
reaper -n http://www.example.com -i 10 # gracefully exit, nudge 10 times
@@ -109,6 +113,8 @@ ARGV.options do |opts|
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", "--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]| }
@@ -119,5 +125,7 @@ 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] \ No newline at end of file
+nudge(OPTIONS[:nudge], OPTIONS[:iterations]) if OPTIONS[:nudge]
+ProgramProcess.process_keywords("usr1", OPTIONS[:spinner]) if OPTIONS[:toggle_spin] \ No newline at end of file