Class: EC2APIProxy::Server

Inherits:
RExec::Daemon::Base show all
Defined in:
lib/ec2-api-proxy/server.rb

Class Method Summary collapse

Methods inherited from RExec::Daemon::Base

daemon_name

Class Method Details

.options=(options) ⇒ Object



18
19
20
21
# File 'lib/ec2-api-proxy/server.rb', line 18

def options=(options)
  @@options = options
  @@base_directory = options[:working_dir]
end

.runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ec2-api-proxy/server.rb', line 23

def run
  @@control_options = {
    :memcached => @@options[:memcached],
    :expires   => @@options[:expires],
    :compress  => @@options[:compress],
    :use_https => @@options[:use_https],
    :debug     => @@options[:debug],
  }

  # start DRb
  FileUtils.rm_f(@@options[:socket])
  DRb.start_service("drbunix:#{@@options[:socket]}", @@control_options)
  File.chmod(0700, @@options[:socket])
  at_exit { FileUtils.rm_f(@@options[:socket]) }

  EM.epoll
  EM.threadpool_size = @@options[:threads] if @@options[:threads]

  EM.run {
    memcached = Dalli::Client.new(@@options[:memcached], :compress => @@options[:compress])
    EM.start_server(@@options[:addr], @@options[:port], EC2APIProxy::Proxy, @@control_options, memcached)
  }
end