Class: ActiveDomain::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/active_domain/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_options = nil) ⇒ Server

Returns a new instance of Server.



10
11
12
# File 'lib/active_domain/server.rb', line 10

def initialize(new_options = nil)
  self.options = new_options.deep_symbolize_keys! unless new_options.nil?
end

Instance Attribute Details

#domainObject



36
37
38
# File 'lib/active_domain/server.rb', line 36

def domain
  @domain ||= ActiveDomain::CommandRoutes.new
end

#optionsObject



32
33
34
# File 'lib/active_domain/server.rb', line 32

def options
  @options ||= parse_options(ARGV)
end

Class Method Details

.run(options = nil) ⇒ Object



6
7
8
# File 'lib/active_domain/server.rb', line 6

def self.run(options = nil)
  new(options).run
end

Instance Method Details

#config_fileObject



43
44
45
# File 'lib/active_domain/server.rb', line 43

def config_file
  self.class.config_file || File.expand_path('config/disco.yml', base_path)
end

#envObject



28
29
30
# File 'lib/active_domain/server.rb', line 28

def env
  @env = ENV['DOMAIN_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_domain/server.rb', line 14

def run
  ActiveRecord::Base.establish_connection options[:domain_database]
  ActiveEvent::EventServer.start options
  drb_uri = URI::Generic.build(options[:drb_server]).to_s
  DRb.start_service(drb_uri, domain, options.fetch(:drb_config, {}))
  DRb.thread.join
rescue Interrupt
  LOGGER.info 'Catching Interrupt'
rescue => e
  LOGGER.error e.message
  LOGGER.error e.backtrace.join("\n")
  raise e
end