Module: Runes::Janitor

Defined in:
lib/runes/janitor.rb

Class Method Summary collapse

Class Method Details

.es_is_running?Boolean

This function was created because rubberband behaves strangely and doesn’t inform properly when elasticsearch isn’t running.

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/runes/janitor.rb', line 19

def es_is_running?
  require 'socket'
  if @config.nil?
    # getting the longer line possible to avoid problems in different operating systems.
    process_status = system("ps auxwwww | grep org.elasticsearch.bootstrap | grep -v grep >> /dev/null")
    return process_status
  else
    net_status = TCPSocket.open(@config['host'], @config['port'].to_i)
    if net_status.nil?
      return false
    else
      return true
    end
  end
end

.setup!Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/runes/janitor.rb', line 4

def setup!
  if Runes::Janitor.es_is_running?
    begin
      Runes::Base.actors.each do |actor|
        $es_client.create_index(actor)
      end
    rescue ElasticSearch::RequestError
      return true
    end
  end
end