Module: ComponentHost

Defined in:
lib/component_host/log.rb,
lib/component_host/host.rb,
lib/component_host/signal.rb,
lib/component_host/controls/name.rb,
lib/component_host/component_host.rb,
lib/component_host/controls/error.rb,
lib/component_host/supervisor_observers/log.rb,
lib/component_host/controls/component_initiator.rb,
lib/component_host/supervisor_observers/record_errors.rb,
lib/component_host/controls/component_initiator/raises_error.rb,
lib/component_host/controls/component_initiator/actor_crashes.rb,
lib/component_host/controls/component_initiator/runs_continuously.rb,
lib/component_host/controls/component_initiator/stops_immediately.rb

Defined Under Namespace

Modules: Controls, Defaults, Signal, SupervisorObservers Classes: Host, Log

Class Method Summary collapse

Class Method Details

.start(name, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/component_host/component_host.rb', line 2

def self.start(name, &block)
  logger = Log.get(self)

  host = Host.build

  host.instance_exec host, &block

  if Defaults.env_var_info?
    STDOUT.puts
    STDOUT.puts RUBY_DESCRIPTION
    STDOUT.puts
    STDOUT.puts "Environment Variables:"
    STDOUT.puts "  ENTITY_CACHE_SCOPE: #{ENV['ENTITY_CACHE_SCOPE'] || '(not set)'}"
    STDOUT.puts "  MESSAGE_STORE_SETTINGS_PATH: #{ENV['MESSAGE_STORE_SETTINGS_PATH'] || '(not set)'}"
    STDOUT.puts "  POLL_INTERVAL_MILLISECONDS: #{ENV['POLL_INTERVAL_MILLISECONDS'] || '(not set)'}"
    STDOUT.puts "  HANDLE_STRICT: #{ENV['HANDLE_STRICT'] || '(not set)'}"
    STDOUT.puts "  LOG_LEVEL: #{ENV['LOG_LEVEL'] || '(not set)'}"
    STDOUT.puts "  LOG_TAGS: #{ENV['LOG_TAGS'] || '(not set)'}"
    STDOUT.puts "  STARTUP_INFO: #{ENV['STARTUP_INFO'] || '(not set)'}"
    STDOUT.puts "  ENV_VAR_INFO: #{ENV['ENV_VAR_INFO'] || '(not set)'}"
  end

  if Defaults.startup_info?
    STDOUT.puts
    STDOUT.puts "Host: #{name}"
  end
  logger.info(tags: [:component_host, :start, :lifecycle]) { "#{RUBY_DESCRIPTION} (Process ID: #{::Process.pid})" }
  logger.info(tags: [:component_host, :start, :lifecycle]) { "Starting host: #{name} (Process ID: #{::Process.pid})" }

  if Defaults.startup_info?
    STDOUT.puts
  end

  host.start do
    if Defaults.startup_info?
      STDOUT.puts
      STDOUT.puts "Host running: #{name}"
      STDOUT.puts "Process ID: #{::Process.pid}"
      STDOUT.puts
      STDOUT.flush
    end

    logger.info(tags: [:component_host, :start, :lifecycle]) { "Started host: #{name} (Process ID: #{::Process.pid})" }
  end
end