Module: Elasticsearch::Manager::CMD

Includes:
Elasticsearch::Manager
Defined in:
lib/elasticsearch/manager/cmd.rb

Constant Summary

Constants included from Elasticsearch::Manager

VERSION

Class Method Summary collapse

Class Method Details

.rolling_restart(opts) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/elasticsearch/manager/cmd.rb', line 13

def self.rolling_restart(opts)
  manager = _manager(opts)
  # Check that the cluster is stable?
  unless manager.cluster_stable?
    print_cluster_status(manager, 'The cluster is currently unstable! Not proceeding with rolling-restart')
    return 2
  end
  puts "Discovering cluster members...\n"
  manager.cluster_members!
  timeout = opts[:timeout] || 600
  sleep_interval = opts[:sleep_interval] || 30
  begin
    manager.rolling_restart(timeout, sleep_interval)
  rescue Exception => e
    puts e
    return 2
  end
  puts 'Rolling restart complete.'
  return 0
end

.status(opts) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/elasticsearch/manager/cmd.rb', line 34

def self.status(opts)
  manager = _manager(opts)
  status = manager.cluster_status
  puts "The Elasticsearch cluster is currently: #{status.colorize(status.to_sym)}"
  print_cluster_status(manager) if opts[:verbose]
  return 0
end