Module: DangoControllerPlugin

Defined in:
lib/dango/controller_plugin/dango_controller_plugin.rb

Overview

モニター用のdangoクライアントクラス

Class Method Summary collapse

Class Method Details

.dango_server_call(method_name, arg, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dango/controller_plugin/dango_controller_plugin.rb', line 19

def self.dango_server_call(method_name, arg, options = {})
  config = dango_server_config(options)
  raise("backdoor_run_drb_server is false.") if !config['server']['backdoor_run_drb_server']
#    drb_uri = "druby://#{config['network']['host']}:#{config['server']['backdoor_run_drb_port']}"
  drb_uri = config['server']['backdoor_run_drb_url']
  begin
    timeout(3) do
      drb_obj = DRbObject.new_with_uri(drb_uri)
      drb_obj.__send__(method_name.to_s, arg)
    end
  rescue Exception
    raise("DRbError:#{$!.class} #{$!.message} #{$!.backtrace.inspect}")
  end
end

.dango_server_config(options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dango/controller_plugin/dango_controller_plugin.rb', line 11

def self.dango_server_config(options = {})
  if !options[:env]
    options[:env] = ENV['RAILS_ENV'] 
  end
  config = YAML.load(open("#{RAILS_ROOT}/config/dango/#{options[:env]}.yml", "rb"){|fh| fh.read})
  config
end