Class: Mamiya::Master

Inherits:
Agent
  • Object
show all
Defined in:
lib/mamiya/master.rb,
lib/mamiya/master/web.rb,
lib/mamiya/master/agent_monitor.rb,
lib/mamiya/master/package_status.rb,
lib/mamiya/master/application_status.rb,
lib/mamiya/master/agent_monitor_handlers.rb

Defined Under Namespace

Modules: AgentMonitorHandlers Classes: AgentMonitor, AppBridge, ApplicationStatus, PackageStatus, Web

Constant Summary collapse

MASTER_EVENTS =
[]

Instance Attribute Summary collapse

Attributes inherited from Agent

#config, #logger, #serf

Instance Method Summary collapse

Methods inherited from Agent

#currents, #existing_packages, #existing_prereleases, #releases, #run!, #stop!, #task_queue, #trigger

Methods included from Util::LabelMatcher

#match?, parse_string_expr

Methods included from Agent::Actions

#distribute, #order_task, #ping, #prepare, #switch

Constructor Details

#initializeMaster

Returns a new instance of Master.



9
10
11
12
13
14
15
# File 'lib/mamiya/master.rb', line 9

def initialize(*)
  super

  @agent_monitor = AgentMonitor.new(self)
  @events_only ||= []
  @events_only << MASTER_EVENTS
end

Instance Attribute Details

#agent_monitorObject (readonly)

Returns the value of attribute agent_monitor.



17
18
19
# File 'lib/mamiya/master.rb', line 17

def agent_monitor
  @agent_monitor
end

Instance Method Details

#applicationsObject



49
50
51
52
53
# File 'lib/mamiya/master.rb', line 49

def applications
  config.storage_class.find(
    config[:storage]
  ).keys
end

#labelsObject



59
60
61
# File 'lib/mamiya/master.rb', line 59

def labels
  []
end

#startObject



29
30
31
32
33
34
# File 'lib/mamiya/master.rb', line 29

def start
  # Override and stop starting task_queue
  web_start
  serf_start
  monitor_start
end

#status(packages: false) ⇒ Object



55
56
57
# File 'lib/mamiya/master.rb', line 55

def status(packages: false)
  {name: serf.name, master: true}
end

#storage(app) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/mamiya/master.rb', line 41

def storage(app)
  config.storage_class.new(
    config[:storage].merge(
      application: app
    )
  )
end

#terminateObject



36
37
38
39
# File 'lib/mamiya/master.rb', line 36

def terminate
  @agent_monitor.stop!
  super
end

#webObject



19
20
21
22
23
24
25
26
27
# File 'lib/mamiya/master.rb', line 19

def web
  logger = self.logger
  this = self

  @web ||= Rack::Builder.new do
    use AppBridge, logger, this
    run Web
  end
end