Skip to content

Instantly share code, notes, and snippets.

@d--j
Created May 27, 2010 16:38
Show Gist options
  • Save d--j/416027 to your computer and use it in GitHub Desktop.
Save d--j/416027 to your computer and use it in GitHub Desktop.
# (1) copy the newrelic rpm java client into #{RAILS_ROOT}/solr/newrelic
# (2) add a newrelic.yml in that directory with you API key
# (3) add this monkey patch in an initializer to load newrelic with the solr server
Sunspot::Server.class_eval do
def run
command = ['java']
command << "-Xms#{min_memory}" if min_memory
command << "-Xmx#{max_memory}" if max_memory
command << "-Djetty.port=#{port}" if port
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir
command << "-Dsolr.solr.home=#{solr_home}" if solr_home
command << "-Djava.util.logging.config.file=#{logging_config_path}" if logging_config_path
command << "-javaagent:#{File.join(Rails.root, 'solr', 'newrelic', 'newrelic.jar')}"
command << "-Dnewrelic.environment=#{Rails.env}"
command << '-jar' << File.basename(solr_jar)
FileUtils.cd(File.dirname(solr_jar)) do
exec(Escape.shell_command(command))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment