Class: MotherBrain::Application::SupervisionGroup

Inherits:
Celluloid::SupervisionGroup
  • Object
show all
Includes:
Celluloid::Notifications, Logging
Defined in:
lib/mb/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

add_argument_header, dev, filename, #log_exception, logger, #logger, reset, set_logger, setup

Constructor Details

#initialize(config) ⇒ SupervisionGroup

Returns a new instance of SupervisionGroup.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/mb/application.rb', line 104

def initialize(config)
  super(MB::Application.registry)

  supervise_as(:config_manager, MB::ConfigManager, config)
  supervise_as(:ridley, Ridley::Client, config.to_ridley)
  supervise_as(:job_manager, MB::JobManager)
  supervise_as(:lock_manager, MB::LockManager)
  supervise_as(:plugin_manager, MB::PluginManager)
  supervise_as(:command_invoker, MB::CommandInvoker)
  supervise_as(:node_querier, MB::NodeQuerier)
  supervise_as(:environment_manager, MB::EnvironmentManager)
  supervise_as(:bootstrap_manager, MB::Bootstrap::Manager)
  supervise_as(:provisioner_manager, MB::Provisioner::Manager)
  supervise_as(:upgrade_manager, MB::Upgrade::Manager)

  if config.rest_gateway.enable
    supervise_as(:rest_gateway, MB::RestGateway, config.to_rest_gateway)
  end

  @interrupt_mutex = Mutex.new
  @interrupted     = false
  subscribe(ConfigManager::UPDATE_MSG, :reconfigure)
  MB::Test.mock(:init) if MB.testing?
end

Instance Attribute Details

#interruptedObject (readonly)

Returns the value of attribute interrupted.



102
103
104
# File 'lib/mb/application.rb', line 102

def interrupted
  @interrupted
end

Instance Method Details

#interruptObject



134
135
136
137
138
139
140
141
# File 'lib/mb/application.rb', line 134

def interrupt
  interrupt_mutex.synchronize do
    unless interrupted
      @interrupted = true
      terminate
    end
  end
end

#reconfigure(_msg, new_config) ⇒ Object



129
130
131
132
# File 'lib/mb/application.rb', line 129

def reconfigure(_msg, new_config)
  log.debug { "[Application] ConfigManager has changed: re-configuring components..." }
  @registry[:ridley].async.configure(new_config.to_ridley)
end