mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
support --clean flag
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@644 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
7f0c23c91a
commit
a3d0ed5909
1 changed files with 8 additions and 5 deletions
|
@ -3,13 +3,14 @@
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
|
||||||
def run(command, verbose)
|
def run(command, verbose, clean=false)
|
||||||
Dir.chdir @options[:conf_path] do
|
Dir.chdir @options[:conf_path] do
|
||||||
confs = Dir.glob("*.yml")
|
confs = Dir.glob("*.yml")
|
||||||
confs += Dir.glob("*.conf")
|
confs += Dir.glob("*.conf")
|
||||||
confs.each do |conf|
|
confs.each do |conf|
|
||||||
cmd = "mongrel_rails cluster::#{command} -C #{conf}"
|
cmd = "mongrel_rails cluster::#{command} -C #{conf}"
|
||||||
cmd += " -v" if verbose
|
cmd += " -v" if verbose
|
||||||
|
cmd += " --clean" if clean
|
||||||
puts cmd if verbose || command == "status"
|
puts cmd if verbose || command == "status"
|
||||||
output = `#{cmd}`
|
output = `#{cmd}`
|
||||||
puts output if verbose || command == "status"
|
puts output if verbose || command == "status"
|
||||||
|
@ -21,12 +22,14 @@ end
|
||||||
@options = {}
|
@options = {}
|
||||||
@options[:conf_path] = "/etc/mongrel_cluster"
|
@options[:conf_path] = "/etc/mongrel_cluster"
|
||||||
@options[:verbose] = false
|
@options[:verbose] = false
|
||||||
|
@options[:clean] = false
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: #{$0} (start|stop|restart|status) [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("-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 }
|
opts.on('-v', '--verbose', "Print all called commands and output.") { |value| @options[:verbose] = value }
|
||||||
|
opts.on('--clean', "Remove pid files if needed beforehand.") { |value| @options[:clean] = value }
|
||||||
|
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
puts opts
|
puts opts
|
||||||
|
@ -49,14 +52,14 @@ end
|
||||||
case @cmd[0]
|
case @cmd[0]
|
||||||
when "start":
|
when "start":
|
||||||
puts "Starting all mongrel_clusters..."
|
puts "Starting all mongrel_clusters..."
|
||||||
run "start", @options[:verbose]
|
run "start", @options[:verbose], @options[:clean]
|
||||||
when "stop":
|
when "stop":
|
||||||
puts "Stopping all mongrel_clusters..."
|
puts "Stopping all mongrel_clusters..."
|
||||||
run "stop", @options[:verbose]
|
run "stop", @options[:verbose], @options[:clean]
|
||||||
when "restart":
|
when "restart":
|
||||||
puts "Restarting all mongrel_clusters..."
|
puts "Restarting all mongrel_clusters..."
|
||||||
run "stop", @options[:verbose]
|
run "stop", @options[:verbose], @options[:clean]
|
||||||
run "start", @options[:verbose]
|
run "start", @options[:verbose], @options[:clean]
|
||||||
when "status":
|
when "status":
|
||||||
puts "Checking all mongrel_clusters..."
|
puts "Checking all mongrel_clusters..."
|
||||||
run "status", @options[:verbose]
|
run "status", @options[:verbose]
|
||||||
|
|
Loading…
Reference in a new issue