Class: SmartProxyDynflowCore::Launcher

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_dynflow_core/launcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.launch!(options) ⇒ Object



7
8
9
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 7

def self.launch!(options)
  self.new.start options
end

.route_mapping(rack_builder) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 32

def self.route_mapping(rack_builder)
  rack_builder.map '/console' do
    run Core.web_console
  end

  rack_builder.map '/' do
    run Api
  end
end

Instance Method Details

#load_settings!(config_dir = nil, one_config = false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 18

def load_settings!(config_dir = nil, one_config = false)
  possible_config_dirs = [
    '/etc/smart_proxy_dynflow_core',
    File.expand_path('~/.config/smart_proxy_dynflow_core'),
    File.join(File.dirname(__FILE__), '..', '..', 'config'),
  ]
  possible_config_dirs << config_dir if config_dir
  BundlerHelper.require_groups(:default)
  possible_config_dirs.reverse! if one_config
  possible_config_dirs.select { |config_dir| File.directory? config_dir }.each do |config_dir|
    break if load_config_dir(config_dir) && one_config
  end
end

#start(options) ⇒ Object



11
12
13
14
15
16
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 11

def start(options)
  load_settings!(options[:config_dir], options[:one_config])
  Settings.instance.standalone = true
  Core.ensure_initialized
  Rack::Server.new(rack_settings).start
end