Class: Cluster::Recovery
- Inherits:
-
Object
- Object
- Cluster::Recovery
- Includes:
- ExecBase
- Defined in:
- lib/mongrel_cluster_recovery/init.rb
Instance Method Summary collapse
Instance Method Details
#configure ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mongrel_cluster_recovery/init.rb', line 12 def configure [ ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/mongrel_cluster.yml"], ['-v', '--verbose', "Print all called commands and output.", :@verbose, false], ['', '--only PORT', "Port number of cluster member", :@only, nil], ['', '--open_timeout sec', "Port test timeout of open", :@open_timeout, 3], ['', '--read_timeout sec', "Port test timeout of read", :@read_timeout, 5], ['', '--url URL', "Port test url", :@url, '/'], ['', '--ip IP', "Port test IP", :@ip, 'localhost'], ] end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mongrel_cluster_recovery/init.rb', line 24 def run @force = true @clean = true @_ports_ = @ports.dup @_ports_.each do |_port_| @only = _port_ if status != Cluster::ExecBase::STATUS_OK stop && start else begin Net::HTTP.version_1_2 http = Net::HTTP.new( @ip, _port_ ) http.open_timeout = @open_timeout http.read_timeout = @read_timeout http.start {|ac| res = http.head(@url) } =begin rescue Errno::ECONNREFUSED => e log e stop && start rescue Timeout::Error => e log e stop && start =end rescue Exception => e log e stop && start else log "ok!" end end end end |