From 3b3c0507e2f67a0f64dc04b396c1d13411ab5890 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 30 Nov 2008 16:23:20 -0600 Subject: Extracted the process scripts (inspector, reaper, spawner) into the plugin irs_process_scripts [DHH] --- railties/lib/commands/process/spinner.rb | 57 -------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 railties/lib/commands/process/spinner.rb (limited to 'railties/lib/commands/process/spinner.rb') diff --git a/railties/lib/commands/process/spinner.rb b/railties/lib/commands/process/spinner.rb deleted file mode 100644 index c0b2f09a94..0000000000 --- a/railties/lib/commands/process/spinner.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'optparse' - -def daemonize #:nodoc: - exit if fork # Parent exits, child continues. - Process.setsid # Become session leader. - exit if fork # Zap session leader. See [1]. - Dir.chdir "/" # Release old working directory. - File.umask 0000 # Ensure sensible umask. Adjust as needed. - STDIN.reopen "/dev/null" # Free file descriptors and - STDOUT.reopen "/dev/null", "a" # point them somewhere sensible. - STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile. -end - -OPTIONS = { - :interval => 5.0, - :command => File.expand_path(RAILS_ROOT + '/script/process/spawner'), - :daemon => false -} - -ARGV.options do |opts| - opts.banner = "Usage: spinner [options]" - - opts.separator "" - - opts.on <<-EOF - Description: - The spinner is a protection loop for the spawner, which will attempt to restart any FCGI processes - that might have been exited 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 light load on the server. - - Examples: - spinner # attempts to run the spawner with default settings every second with output on the terminal - spinner -i 3 -d # only run the spawner every 3 seconds and detach from the terminal to become a daemon - spinner -c '/path/to/app/script/process/spawner -p 9000 -i 10' -d # using custom spawner - EOF - - opts.on(" Options:") - - opts.on("-c", "--command=path", String) { |v| OPTIONS[:command] = v } - opts.on("-i", "--interval=seconds", Float) { |v| OPTIONS[:interval] = v } - opts.on("-d", "--daemon") { |v| OPTIONS[:daemon] = v } - - opts.separator "" - - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } - - opts.parse! -end - -daemonize if OPTIONS[:daemon] - -trap(OPTIONS[:daemon] ? "TERM" : "INT") { exit } - -loop do - system(OPTIONS[:command]) - sleep(OPTIONS[:interval]) -end \ No newline at end of file -- cgit v1.2.3