Class: Droonga::Command::SerfEventHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/command/serf_event_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSerfEventHandler

Returns a new instance of SerfEventHandler.



30
31
32
# File 'lib/droonga/command/serf_event_handler.rb', line 30

def initialize
  @payload = nil
end

Class Method Details

.runObject



25
26
27
# File 'lib/droonga/command/serf_event_handler.rb', line 25

def run
  new.run
end

Instance Method Details

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/droonga/command/serf_event_handler.rb', line 34

def run
  command_class = detect_command_class
  return true if command_class.nil?

  serf_name = ENV["SERF_SELF_NAME"]
  command = command_class.new(serf_name, @payload)
  command.process if command.should_process?
  output_response(command.response)
  true
rescue Exception => exception
  #XXX Any exception blocks following serf operations.
  #    To keep it working, I rescue any exception for now.
  FileUtils.mkdir_p(Path.serf_event_handler_errors)
  File.open(Path.serf_event_handler_error_file, "w") do |file|
    file.write(exception.inspect)
    file.write(exception.backtrace)
  end
  true
end