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