Class: Daemons::Rails::Monitoring

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/daemons/rails/monitoring.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(daemons_path = nil) ⇒ Monitoring

Returns a new instance of Monitoring.



18
19
20
# File 'lib/daemons/rails/monitoring.rb', line 18

def initialize(daemons_path = nil)
  @daemons_path = daemons_path
end

Class Method Details

.daemons_directoryObject



28
29
30
# File 'lib/daemons/rails/monitoring.rb', line 28

def self.daemons_directory
  self.daemons_path
end

.daemons_directory=(value) ⇒ Object



23
24
25
# File 'lib/daemons/rails/monitoring.rb', line 23

def self.daemons_directory=(value)
  self.daemons_path = value
end

.defaultObject



14
15
16
# File 'lib/daemons/rails/monitoring.rb', line 14

def self.default
  @default ||= self.new
end

Instance Method Details

#controller(app_name) ⇒ Object



40
41
42
# File 'lib/daemons/rails/monitoring.rb', line 40

def controller(app_name)
  controllers.find { |controller| controller.app_name == app_name }
end

#controllersObject



44
45
46
# File 'lib/daemons/rails/monitoring.rb', line 44

def controllers
  Pathname.glob(daemons_path.join('*_ctl')).map { |path| Daemons::Rails::Controller.new(path) }
end

#daemons_pathObject



36
37
38
# File 'lib/daemons/rails/monitoring.rb', line 36

def daemons_path
  @daemons_path || Daemons::Rails.configuration.daemons_path
end

#daemons_path=(value) ⇒ Object



32
33
34
# File 'lib/daemons/rails/monitoring.rb', line 32

def daemons_path=(value)
  @daemons_path = value
end

#start(app_name) ⇒ Object



52
53
54
# File 'lib/daemons/rails/monitoring.rb', line 52

def start(app_name)
  controller(app_name).start
end

#statusesObject



48
49
50
# File 'lib/daemons/rails/monitoring.rb', line 48

def statuses
  controllers.each_with_object({}) { |controller, statuses| statuses[controller.app_name] = controller.status }
end

#stop(app_name) ⇒ Object



56
57
58
# File 'lib/daemons/rails/monitoring.rb', line 56

def stop(app_name)
  controller(app_name).stop
end