diff --git a/README.md b/README.md index e9c2bd4a..752bae0e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Description =========== -This cookbook provides an easy way to install various New Relic agent and the New Relic server monitor. +This cookbook provides an easy way to install various New Relic agents and the New Relic server monitor. More information? * https://newrelic.com/docs/server/new-relic-for-server-monitoring @@ -138,20 +138,22 @@ Attributes * `node['newrelic']['log_daily']` - Override other log rolling configuration and roll the logs daily ## nodejs-agent.rb -* node['newrelic']['nodejs']['apps'] - Array of Hash describing the apps to monitor: +* node['newrelic']['nodejs']['apps'] - Array of Hash describing the apps to monitor + +eg. ``` [ { 'app_name' => 'My Application', 'app_path' => "/path/to/app/root" } - ] +] ``` You then need to modify your application "main" file to add the following on the first line: -```javascript +``` +javascript require('newrelic'); ``` - Resources / Providers ===================== diff --git a/attributes/nodejs-agent.rb b/attributes/nodejs-agent.rb index 8bae8b31..63ba10ac 100644 --- a/attributes/nodejs-agent.rb +++ b/attributes/nodejs-agent.rb @@ -1,11 +1,9 @@ +# # Cookbook Name:: newrelic # Attributes:: nodejs-agent # -# MIT Licensed +# Copyright 2012-2013, Escape Studios +# -# Array of Hash describing the apps to monitor: -# [ -# { 'app_name' => 'My Application', 'app_path' => "/path/to/app/root" } -# ] default['newrelic']['nodejs']['apps'] = [] - +default['newrelic']['nodejs_recipe'] = "nodejs::npm" \ No newline at end of file diff --git a/metadata.rb b/metadata.rb index e05e69b3..a727290d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs/Configures New Relic" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.5.7" +version "0.5.8" %w{ debian ubuntu redhat centos fedora scientific amazon windows smartos }.each do |os| supports os @@ -22,4 +22,4 @@ recipe "newrelic::php-agent", "Installs the New Relic PHP agent." recipe "newrelic::python-agent", "Installs the New Relic Python agent." recipe "newrelic::dotnet", "Installs New Relic .NET Agent" -recipe "newrelic::nodejs", "Installs New Relic Node.js Agent" +recipe "newrelic::nodejs", "Installs New Relic Node.js Agent" \ No newline at end of file diff --git a/recipes/nodejs-agent.rb b/recipes/nodejs-agent.rb index 381e831c..239de868 100644 --- a/recipes/nodejs-agent.rb +++ b/recipes/nodejs-agent.rb @@ -2,24 +2,23 @@ # Cookbook Name:: newrelic # Recipe:: nodejs-agent # -# Copyright 2014, La Presse -# MIT License +# Copyright 2012-2013, Escape Studios # +include_recipe node['newrelic']['nodejs_recipe'] -include_recipe "nodejs::npm" - - -# Install the newrelic.js file into each projects +#install the newrelic.js file into each projects node['newrelic']['nodejs']['apps'].each do |nodeapp| - execute "npm-install-nodejs-agent" do - #not_if "" - # creates - cwd nodeapp['app_path'] - command "npm install newrelic" - end - template "#{nodeapp['app_path']}/newrelic.js" do - source "newrelic.js.erb" - variables :app_name => nodeapp['app_name'], :app_log_level => "INFO" - end -end + execute "npm-install-nodejs-agent" do + cwd nodeapp['app_path'] + command "npm install newrelic" + end + + template "#{nodeapp['app_path']}/newrelic.js" do + source "newrelic.js.erb" + variables( + :app_name => nodeapp['app_name'], + :app_log_level => "INFO" + ) + end +end \ No newline at end of file diff --git a/templates/default/newrelic.js.erb b/templates/default/newrelic.js.erb index f05670b1..569b55be 100644 --- a/templates/default/newrelic.js.erb +++ b/templates/default/newrelic.js.erb @@ -1,7 +1,7 @@ /** - * THIS FILE IS MANAGED BY CHEF - * ALL MODIFICATIONS WILL BE LOSTS - * TO EDIT, SEE newrelic COOKBOOK AT .../templates/default/newrelic.js.erb + * ################### + * # Generated by Chef + * ################### * * New Relic agent configuration. * @@ -9,20 +9,20 @@ * description of configuration variables and their potential values. */ exports.config = { - /** - * Array of application names. - */ - app_name : ['<%= @app_name %>'], - /** - * Your New Relic license key. - */ - license_key : '<%= node['newrelic']['application_monitoring']['license'] %>', - logging : { /** - * Level at which to log. 'trace' is most useful to New Relic when diagnosing - * issues with the agent, 'info' and higher will impose the least overhead on - * production applications. + * Array of application names. */ - level : '<%= @app_log_level %>' - } -}; + app_name: ['<%= @app_name %>'], + /** + * Your New Relic license key. + */ + license_key: '<%= node['newrelic']['application_monitoring']['license'] %>', + logging: { + /** + * Level at which to log. 'trace' is most useful to New Relic when diagnosing + * issues with the agent, 'info' and higher will impose the least overhead on + * production applications. + */ + level: '<%= @app_log_level %>' + } +}; \ No newline at end of file