Class: SmartProxyDynflowCore::Launcher

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

Constant Summary collapse

CIPHERS =
['ECDHE-RSA-AES128-GCM-SHA256', 'ECDHE-RSA-AES256-GCM-SHA384',
'AES128-GCM-SHA256', 'AES256-GCM-SHA384', 'AES128-SHA256',
'AES256-SHA256', 'AES128-SHA', 'AES256-SHA'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.launch!(options) ⇒ Object



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

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

.route_mapping(rack_builder) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 44

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

#install_usr1_trapObject



54
55
56
57
58
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 54

def install_usr1_trap
  trap(:USR1) do
    Log.instance.roll_log
  end
end

#load_settings!(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 26

def load_settings!(options = {})
  config_dir, one_config = options.values_at(:config_dir, :one_config)
  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
  Settings.instance.daemonize = options[:daemonize] if options.key?(:daemonize)
  Settings.instance.pid_file = options[:pid_file] if options.key?(:pid_file)
  Settings.loaded!
end

#start(options) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/smart_proxy_dynflow_core/launcher.rb', line 16

def start(options)
  load_settings!(options)
  Settings.instance.standalone = true
  install_usr1_trap
  Rack::Server.new(rack_settings).start do |_server|
    SmartProxyDynflowCore::Core.ensure_initialized
    SmartProxyDynflowCore::SdNotify.new.tap { |sd| sd.ready if sd.active? }
  end
end