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.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/mb/application.rb', line 136

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.



134
135
136
# File 'lib/mb/application.rb', line 134

def interrupted
  @interrupted
end

Instance Method Details

#async_interrupt(delay = 0) ⇒ Object



166
167
168
# File 'lib/mb/application.rb', line 166

def async_interrupt(delay = 0)
  future.interrupt(delay)
end

#interrupt(delay = 0) ⇒ Object



170
171
172
173
174
175
176
177
178
# File 'lib/mb/application.rb', line 170

def interrupt(delay = 0)
  Celluloid.sleep(delay) if delay > 0
  interrupt_mutex.synchronize do
    unless interrupted
      @interrupted = true
      terminate
    end
  end
end

#reconfigure(_msg, new_config) ⇒ Object



161
162
163
164
# File 'lib/mb/application.rb', line 161

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