Module: Fiveruns::Dash::Rails
- Defined in:
- lib/fiveruns/dash/rails.rb,
lib/fiveruns/dash/rails/version.rb
Defined Under Namespace
Modules: ActionContext, Hash, Initializer, TemplateContext
Classes: Version
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.server ⇒ Object
Returns the value of attribute server.
12
13
14
|
# File 'lib/fiveruns/dash/rails.rb', line 12
def server
@server
end
|
Class Method Details
70
71
72
73
74
75
76
77
|
# File 'lib/fiveruns/dash/rails.rb', line 70
def self.configure(tokens = {}, &block)
tokens.each do |environment, token|
if environment.to_s == self.env
Fiveruns::Dash.configure({:app => token}, &block)
break
end
end
end
|
.dash_start_block ⇒ Object
65
66
67
|
# File 'lib/fiveruns/dash/rails.rb', line 65
def self.dash_start_block
@dash_start_block ||= lambda {}
end
|
.env ⇒ Object
95
96
97
98
99
|
# File 'lib/fiveruns/dash/rails.rb', line 95
def self.env
::Rails.env rescue
ENV['RAILS_ENV'] end
|
.load_recipes ⇒ Object
41
42
43
44
45
|
# File 'lib/fiveruns/dash/rails.rb', line 41
def self.load_recipes
Dir[File.dirname(__FILE__) << "/recipes/**/*.rb"].each do |file|
require file
end
end
|
.log_error ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/fiveruns/dash/rails.rb', line 79
def self.log_error
message =<<-EOM
FiveRuns Dash [Rails] (v#{Version::STRING}) Application token missing
===
In config/initializers/dash.rb or at the bottom of config/environment.rb, please add:
Fiveruns::Dash::Rails.configure :#{env} => 'YOUR-#{env.upcase}-ENV-APP-TOKEN-HERE'
You can also set app tokens for other environments (eg, staging), at the same time.
See http://todo/path/to/help for more information
===
EOM
RAILS_DEFAULT_LOGGER.warn(message.strip)
end
|
.queue_size ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/fiveruns/dash/rails.rb', line 15
def self.queue_size
return 0 unless server_type
case server_type
when :mongrel
server.workers.list.length
else
0 end
end
|
.server_type ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fiveruns/dash/rails.rb', line 25
def self.server_type
return @server_type if defined?(@server_type)
@server_type = if server
case server.class.to_s
when /Mongrel/
:mongrel
else
::Fiveruns::Dash.logger.warn "Unrecognized app server type: #{server.class}, not collecting queue size"
false
end
else
::Fiveruns::Dash.logger.warn "Could not find app server, not collecting queue size"
nil
end
end
|
.start(tokens = {}, &block) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fiveruns/dash/rails.rb', line 47
def self.start(tokens = {}, &block)
return if Fiveruns::Dash.session.reporter.started?
::Rails::Initializer.send(:include, Fiveruns::Dash::Rails::Initializer)
store_dash_start_block do
configure(tokens, &block) unless tokens.empty?
if Fiveruns::Dash.configuration.ready?
RAILS_DEFAULT_LOGGER.info "Starting Dash"
Fiveruns::Dash.session.start
else
log_error unless env == 'development'
end
end
end
|
.store_dash_start_block(&block) ⇒ Object
61
62
63
|
# File 'lib/fiveruns/dash/rails.rb', line 61
def self.store_dash_start_block(&block)
@dash_start_block = block
end
|