scout_rails 1.0.0 → 1.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.1.pre
2
+
3
+ * Unicorn support (requires "preload_app true" in unicorn config file)
4
+
1
5
  # 1.0.0
2
6
 
3
7
  Release!
@@ -50,6 +50,7 @@ module ScoutRails
50
50
  def start(options = {})
51
51
  @options.merge!(options)
52
52
  init_logger
53
+ logger.info "Attempting to start Scout Agent [#{ScoutRails::VERSION}] on [#{Socket.gethostname}]"
53
54
  if !config.settings['monitor'] and !@options[:force]
54
55
  logger.warn "Monitoring isn't enabled for the [#{environment.env}] environment."
55
56
  return false
@@ -66,11 +67,12 @@ module ScoutRails
66
67
  if !start_worker_thread?
67
68
  logger.debug "Not starting worker thread"
68
69
  install_passenger_worker_process_event if environment.passenger?
70
+ install_unicorn_worker_loop if environment.unicorn?
69
71
  return
70
72
  end
71
73
  start_worker_thread
72
74
  handle_exit
73
- log_version_pid
75
+ logger.info "Scout Agent [#{ScoutRails::VERSION}] Initialized"
74
76
  end
75
77
 
76
78
  # Placeholder: store metrics locally on exit so those in memory aren't lost. Need to decide
@@ -116,8 +118,15 @@ module ScoutRails
116
118
  end
117
119
  end
118
120
 
119
- def log_version_pid
120
- logger.info "Scout Agent [#{ScoutRails::VERSION}] Initialized"
121
+ def install_unicorn_worker_loop
122
+ logger.debug "Installing Unicorn worker loop."
123
+ Unicorn::HttpServer.class_eval do
124
+ old = instance_method(:worker_loop)
125
+ define_method(:worker_loop) do |worker|
126
+ ScoutRails::Agent.instance.start_worker_thread
127
+ old.bind(self).call(worker)
128
+ end
129
+ end
121
130
  end
122
131
 
123
132
  def log_path
@@ -131,7 +140,7 @@ module ScoutRails
131
140
 
132
141
  # Creates the worker thread. The worker thread is a loop that runs continuously. It sleeps for +Agent#period+ and when it wakes,
133
142
  # processes data, either saving it to disk or reporting to Scout.
134
- def start_worker_thread(connection_options = {})
143
+ def start_worker_thread
135
144
  logger.debug "Creating worker thread."
136
145
  @worker_thread = Thread.new do
137
146
  begin
@@ -39,6 +39,7 @@ module ScoutRails
39
39
  @app_server ||= if thin? then :thin
40
40
  elsif passenger? then :passenger
41
41
  elsif webrick? then :webrick
42
+ elsif unicorn? then :unicorn
42
43
  else nil
43
44
  end
44
45
  end
@@ -60,10 +61,17 @@ module ScoutRails
60
61
  defined?(::WEBrick) && defined?(::WEBrick::VERSION)
61
62
  end
62
63
 
64
+ def unicorn?
65
+ if defined?(::Unicorn) && defined?(::Unicorn::HttpServer)
66
+ # ensure Unicorn is actually initialized.
67
+ ObjectSpace.each_object(::Unicorn::HttpServer) { |x| return true }
68
+ end
69
+ end
70
+
63
71
  # If forking, don't start worker thread in the master process. Since it's started as a Thread, it won't survive
64
72
  # the fork.
65
73
  def forking?
66
- passenger?
74
+ passenger? or unicorn?
67
75
  end
68
76
 
69
77
  ### ruby checks
@@ -1,3 +1,3 @@
1
1
  module ScoutRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1.pre"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1.pre
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derek Haynes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-16 00:00:00.000000000 Z
13
+ date: 2012-07-17 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Monitors a Ruby on Rails application and reports detailed metrics on
16
16
  performance to Scout, a hosted monitoring service.
@@ -61,9 +61,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
- - - ! '>='
64
+ - - ! '>'
65
65
  - !ruby/object:Gem::Version
66
- version: '0'
66
+ version: 1.3.1
67
67
  requirements: []
68
68
  rubyforge_project: scout_rails
69
69
  rubygems_version: 1.8.10