-
-
Save newrelic/328629 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Job | |
def self.perform_with_newrelic(*args) | |
NewRelic::Control.instance['forked_job'] = true | |
perform(*args) | |
NewRelic::Agent.shutdown | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NewRelic | |
module Agent | |
class Agent | |
def ensure_worker_thread_started | |
return unless control.agent_enabled? && control.monitor_mode? && !@invalid_license | |
if !running? && !control['forked_job'] | |
# We got some reports of threading errors in Unicorn with this. | |
log.debug "Detected that the worker loop is not running. Restarting." rescue nil | |
# Assume we've been forked, clear out stats that are left over from parent process | |
reset_stats | |
launch_worker_thread | |
@stats_engine.spawn_sampler_thread | |
end | |
end | |
end | |
end | |
end | |
module Resque | |
class Job | |
def perform | |
args ? payload_class.perform_with_newrelic(*args) : payload_class.perform_with_newrelic | |
end | |
end | |
end | |
Resque.after_fork do |job| | |
ActiveRecord::Base.connection.reconnect! | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task "resque:setup" => :environment do | |
NewRelic::Agent.manual_start :app_name => 'fc-staging'#ENV['APP_NAME'] | |
end | |
desc "Alias for resque:work (To run workers on Heroku)" | |
task "jobs:work" => "resque:work" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment