Skip to content

Instantly share code, notes, and snippets.

@malomalo
Created March 9, 2010 19:18
Show Gist options
  • Save malomalo/326973 to your computer and use it in GitHub Desktop.
Save malomalo/326973 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment