Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -urN mongrel_cluster-0.2.0.orig/bin/mongrel_cluster_ctl mongrel_cluster-0.2.0/bin/mongrel_cluster_ctl
- --- mongrel_cluster-0.2.0.orig/bin/mongrel_cluster_ctl Sat Jul 29 21:42:19 2006
- +++ mongrel_cluster-0.2.0/bin/mongrel_cluster_ctl Sat Jul 29 21:41:59 2006
- @@ -3,14 +3,14 @@
- require 'optparse'
- -def run(command, verbose)
- +def run(command, verbose, status = nil)
- Dir.chdir @options[:conf_path] do
- Dir.glob("*.yml").each do |config|
- cmd = "mongrel_rails cluster::#{command} -c #{config}"
- cmd += " -v" if verbose
- puts cmd if verbose
- output = `#{cmd}`
- - puts output if verbose
- + puts output if verbose || status
- puts "mongrel_rails cluster::#{command} returned an error." unless $?.success?
- end
- end
- @@ -21,7 +21,7 @@
- @options[:verbose] = false
- OptionParser.new do |opts|
- - opts.banner = "Usage: #{$0} (start|stop|restart) [options]"
- + opts.banner = "Usage: #{$0} (start|stop|restart|status) [options]"
- opts.on("-c", "--conf_path PATH", "Path to mongrel_cluster configuration files") { |value| @options[:conf_path] = value }
- opts.on('-v', '--verbose', "Print all called commands and output.") { |value| @options[:verbose] = value }
- @@ -55,8 +55,10 @@
- puts "Restarting all mongrel_clusters..."
- run "stop", @options[:verbose]
- run "start", @options[:verbose]
- +when "status":
- + run "status", @options[:verbose], true
- else
- puts "Unknown command."
- end
- -exit
- \ No newline at end of file
- +exit
- diff -urN mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/init.rb mongrel_cluster-0.2.0/lib/mongrel_cluster/init.rb
- --- mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/init.rb Sat Jul 29 21:42:19 2006
- +++ mongrel_cluster-0.2.0/lib/mongrel_cluster/init.rb Sat Jul 29 21:50:10 2006
- @@ -152,6 +152,46 @@
- end
- end
- + class Status < GemPlugin::Plugin "/commands"
- + include Mongrel::Command::Base
- +
- + def configure
- + options [
- + ['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
- + ['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
- + ]
- + end
- +
- + def validate
- + valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
- + return @valid
- + end
- +
- + def run
- + @options = {
- + "environment" => ENV['RAILS_ENV'] || "development",
- + "port" => 3000,
- + "pid_file" => "log/mongrel.pid",
- + "servers" => 2
- + }
- +
- + @conf_options = YAML.load_file(@config_file)
- + @options.merge! @conf_options if @conf_options
- + port = @options["port"].to_i - 1
- + pid = @options["pid_file"].split(".")
- + puts "#{@options["servers"]} Mongrel servers running form #{@config_file}."
- + 1.upto(@options["servers"].to_i) do |i|
- + port_pid_file = "#{@options["cwd"]}/#{pid[0]}.#{port+i}.#{pid[1]}"
- + if File.exists?(port_pid_file)
- + port_pid = File.open(port_pid_file).readlines
- + puts "mongrel at #{port+i} running as #{port_pid}."
- + else
- + puts "missing pid for mongrel at #{port+i}"
- + end
- + end
- + end
- + end
- +
- class Configure < GemPlugin::Plugin "/commands"
- include Mongrel::Command::Base
- diff -urN mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/recipes.rb mongrel_cluster-0.2.0/lib/mongrel_cluster/recipes.rb
- --- mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/recipes.rb Sat Jul 29 21:42:19 2006
- +++ mongrel_cluster-0.2.0/lib/mongrel_cluster/recipes.rb Sat Jul 29 21:41:59 2006
- @@ -48,6 +48,14 @@
- end
- desc <<-DESC
- + Display the status of the Mongrel processes on the app server.
- + DESC
- + task :status_mongrel_cluster , :roles => :app do
- + set_mongrel_conf
- + send(run_method, "mongrel_rails cluster::status -C #{mongrel_conf}")
- + end
- +
- + desc <<-DESC
- Stop the Mongrel processes on the app server. This uses the :use_sudo
- variable to determine whether to use sudo or not. By default, :use_sudo is
- set to true.
- @@ -75,4 +83,4 @@
- set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
- end
- -end
- \ No newline at end of file
- +end
Add Comment
Please, Sign In to add comment