aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin/process/spinner
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/spinner
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/spinner')
-rwxr-xr-xrailties/bin/process/spinner31
1 files changed, 19 insertions, 12 deletions
diff --git a/railties/bin/process/spinner b/railties/bin/process/spinner
index ff7a576163..f4cd33cac1 100755
--- a/railties/bin/process/spinner
+++ b/railties/bin/process/spinner
@@ -14,9 +14,10 @@ def daemonize
end
OPTIONS = {
- :interval => 1.0,
- :command => File.expand_path(File.dirname(__FILE__) + '/spawner'),
- :daemon => false
+ :high_interval => 5.0,
+ :low_interval => 0.5,
+ :command => File.expand_path(File.dirname(__FILE__) + '/spawner'),
+ :daemon => false
}
ARGV.options do |opts|
@@ -28,8 +29,7 @@ ARGV.options do |opts|
Description:
The spinner is a protection loop for the spawner, which will attempt to restart any FCGI processes
that might have been restarted or outright crashed. It's a brute-force attempt that'll just try
- to run the spawner every X number of seconds, so it does pose a load on the server (~1% on our test
- server).
+ to run the spawner every X number of seconds, so it does pose a light load on the server.
Examples:
spinner # attempts to run the spawner with default settings every second with output on the terminal
@@ -39,9 +39,10 @@ ARGV.options do |opts|
opts.on(" Options:")
- opts.on("-c", "--command=path", String) { |OPTIONS[:command]| }
- opts.on("-i", "--interval=seconds", Float) { |OPTIONS[:interval]| }
- opts.on("-d", "--daemon") { |OPTIONS[:daemon]| }
+ opts.on("-c", "--command=path", String) { |OPTIONS[:command]| }
+ opts.on("-h", "--high-interval=seconds", Float) { |OPTIONS[:high_interval]| }
+ opts.on("-l", "--low-interval=seconds", Float) { |OPTIONS[:low_interval]| }
+ opts.on("-d", "--daemon") { |OPTIONS[:daemon]| }
opts.separator ""
@@ -52,9 +53,15 @@ end
daemonize if OPTIONS[:daemon]
-loop do
- system(OPTIONS[:command])
- sleep(OPTIONS[:interval])
+trap(OPTIONS[:daemon] ? "TERM" : "INT") { exit }
+trap("USR1") do
+ $interval = ($interval == OPTIONS[:high_interval] ? OPTIONS[:low_interval] : OPTIONS[:high_interval])
+ puts "New interval: #{$interval}"
end
-trap(OPTIONS[:daemon] ? "TERM" : "INT") { exit } \ No newline at end of file
+$interval = OPTIONS[:high_interval]
+
+loop do
+ system(OPTIONS[:command])
+ sleep($interval)
+end \ No newline at end of file