Guest User

Untitled

a guest
Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. diff -urN mongrel_cluster-0.2.0.orig/bin/mongrel_cluster_ctl mongrel_cluster-0.2.0/bin/mongrel_cluster_ctl
  2. --- mongrel_cluster-0.2.0.orig/bin/mongrel_cluster_ctl Sat Jul 29 21:42:19 2006
  3. +++ mongrel_cluster-0.2.0/bin/mongrel_cluster_ctl Sat Jul 29 21:41:59 2006
  4. @@ -3,14 +3,14 @@
  5.  
  6. require 'optparse'
  7.  
  8. -def run(command, verbose)
  9. +def run(command, verbose, status = nil)
  10. Dir.chdir @options[:conf_path] do
  11. Dir.glob("*.yml").each do |config|
  12. cmd = "mongrel_rails cluster::#{command} -c #{config}"
  13. cmd += " -v" if verbose
  14. puts cmd if verbose
  15. output = `#{cmd}`
  16. - puts output if verbose
  17. + puts output if verbose || status
  18. puts "mongrel_rails cluster::#{command} returned an error." unless $?.success?
  19. end
  20. end
  21. @@ -21,7 +21,7 @@
  22. @options[:verbose] = false
  23.  
  24. OptionParser.new do |opts|
  25. - opts.banner = "Usage: #{$0} (start|stop|restart) [options]"
  26. + opts.banner = "Usage: #{$0} (start|stop|restart|status) [options]"
  27.  
  28. opts.on("-c", "--conf_path PATH", "Path to mongrel_cluster configuration files") { |value| @options[:conf_path] = value }
  29. opts.on('-v', '--verbose', "Print all called commands and output.") { |value| @options[:verbose] = value }
  30. @@ -55,8 +55,10 @@
  31. puts "Restarting all mongrel_clusters..."
  32. run "stop", @options[:verbose]
  33. run "start", @options[:verbose]
  34. +when "status":
  35. + run "status", @options[:verbose], true
  36. else
  37. puts "Unknown command."
  38. end
  39.  
  40. -exit
  41. \ No newline at end of file
  42. +exit
  43. diff -urN mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/init.rb mongrel_cluster-0.2.0/lib/mongrel_cluster/init.rb
  44. --- mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/init.rb Sat Jul 29 21:42:19 2006
  45. +++ mongrel_cluster-0.2.0/lib/mongrel_cluster/init.rb Sat Jul 29 21:50:10 2006
  46. @@ -152,6 +152,46 @@
  47. end
  48. end
  49.  
  50. + class Status < GemPlugin::Plugin "/commands"
  51. + include Mongrel::Command::Base
  52. +
  53. + def configure
  54. + options [
  55. + ['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
  56. + ['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
  57. + ]
  58. + end
  59. +
  60. + def validate
  61. + valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
  62. + return @valid
  63. + end
  64. +
  65. + def run
  66. + @options = {
  67. + "environment" => ENV['RAILS_ENV'] || "development",
  68. + "port" => 3000,
  69. + "pid_file" => "log/mongrel.pid",
  70. + "servers" => 2
  71. + }
  72. +
  73. + @conf_options = YAML.load_file(@config_file)
  74. + @options.merge! @conf_options if @conf_options
  75. + port = @options["port"].to_i - 1
  76. + pid = @options["pid_file"].split(".")
  77. + puts "#{@options["servers"]} Mongrel servers running form #{@config_file}."
  78. + 1.upto(@options["servers"].to_i) do |i|
  79. + port_pid_file = "#{@options["cwd"]}/#{pid[0]}.#{port+i}.#{pid[1]}"
  80. + if File.exists?(port_pid_file)
  81. + port_pid = File.open(port_pid_file).readlines
  82. + puts "mongrel at #{port+i} running as #{port_pid}."
  83. + else
  84. + puts "missing pid for mongrel at #{port+i}"
  85. + end
  86. + end
  87. + end
  88. + end
  89. +
  90. class Configure < GemPlugin::Plugin "/commands"
  91. include Mongrel::Command::Base
  92.  
  93. diff -urN mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/recipes.rb mongrel_cluster-0.2.0/lib/mongrel_cluster/recipes.rb
  94. --- mongrel_cluster-0.2.0.orig/lib/mongrel_cluster/recipes.rb Sat Jul 29 21:42:19 2006
  95. +++ mongrel_cluster-0.2.0/lib/mongrel_cluster/recipes.rb Sat Jul 29 21:41:59 2006
  96. @@ -48,6 +48,14 @@
  97. end
  98.  
  99. desc <<-DESC
  100. + Display the status of the Mongrel processes on the app server.
  101. + DESC
  102. + task :status_mongrel_cluster , :roles => :app do
  103. + set_mongrel_conf
  104. + send(run_method, "mongrel_rails cluster::status -C #{mongrel_conf}")
  105. + end
  106. +
  107. + desc <<-DESC
  108. Stop the Mongrel processes on the app server. This uses the :use_sudo
  109. variable to determine whether to use sudo or not. By default, :use_sudo is
  110. set to true.
  111. @@ -75,4 +83,4 @@
  112. set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
  113. end
  114.  
  115. -end
  116. \ No newline at end of file
  117. +end
Add Comment
Please, Sign In to add comment