From 8872b36a0f1be65bd3d90b818cf890a3560519a4 Mon Sep 17 00:00:00 2001 From: bktaylor Date: Fri, 26 Jan 2007 01:50:22 +0000 Subject: [PATCH] Added stupport for status git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@518 19e92222-5c0b-0410-8929-a290d50e31e9 --- projects/mongrel_cluster/bin/mongrel_cluster_ctl | 13 ++++++++----- .../mongrel_cluster/lib/mongrel_cluster/recipes.rb | 12 +++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/projects/mongrel_cluster/bin/mongrel_cluster_ctl b/projects/mongrel_cluster/bin/mongrel_cluster_ctl index a21e162b..9af72f88 100755 --- a/projects/mongrel_cluster/bin/mongrel_cluster_ctl +++ b/projects/mongrel_cluster/bin/mongrel_cluster_ctl @@ -8,11 +8,11 @@ def run(command, verbose) confs = Dir.glob("*.yml") confs += Dir.glob("*.conf") confs.each do |conf| - cmd = "mongrel_rails cluster::#{command} -c #{conf}" + cmd = "mongrel_rails cluster::#{command} -C #{conf}" cmd += " -v" if verbose - puts cmd if verbose + puts cmd if verbose || command == "status" output = `#{cmd}` - puts output if verbose + puts output if verbose || command == "status" puts "mongrel_rails cluster::#{command} returned an error." unless $?.success? end end @@ -23,7 +23,7 @@ end @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 } @@ -57,8 +57,11 @@ when "restart": puts "Restarting all mongrel_clusters..." run "stop", @options[:verbose] run "start", @options[:verbose] +when "status": + puts "Checking all mongrel_clusters..." + run "status", @options[:verbose] else puts "Unknown command." end -exit \ No newline at end of file +exit diff --git a/projects/mongrel_cluster/lib/mongrel_cluster/recipes.rb b/projects/mongrel_cluster/lib/mongrel_cluster/recipes.rb index 55d9cd21..999a7064 100644 --- a/projects/mongrel_cluster/lib/mongrel_cluster/recipes.rb +++ b/projects/mongrel_cluster/lib/mongrel_cluster/recipes.rb @@ -58,6 +58,16 @@ Capistrano.configuration(:must_exist).load do set_mongrel_conf send(run_method, "mongrel_rails cluster::stop -C #{mongrel_conf}") end + + desc <<-DESC + Check the status of 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. + DESC + task :status_mongrel_cluster , :roles => :app do + set_mongrel_conf + send(run_method, "mongrel_rails cluster::status -C #{mongrel_conf}") + end desc <<-DESC Restart the Mongrel processes on the app server by calling restart_mongrel_cluster. @@ -77,4 +87,4 @@ Capistrano.configuration(:must_exist).load do set :mongrel_conf, "/etc/mongrel_cluster/#{application}.yml" unless mongrel_conf end -end \ No newline at end of file +end