newrelic: fix newrelic starting without license key.
Fix an issue where the New Relic agent always started in the production environment, even when a license key wasn't configured. Also make the New Relic agent log to stdout instead of log/newrelic_agent.log.
This commit is contained in:
@@ -581,6 +581,12 @@ module Danbooru
|
||||
def redis_url
|
||||
# "redis://localhost:6379"
|
||||
end
|
||||
|
||||
# Optional. The license key for your New Relic account.
|
||||
# https://newrelic.com/
|
||||
# https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/new-relic-license-key/
|
||||
def new_relic_license_key
|
||||
end
|
||||
end
|
||||
|
||||
EnvironmentConfiguration = Struct.new(:config) do
|
||||
|
||||
14
config/initializers/00_newrelic.rb
Normal file
14
config/initializers/00_newrelic.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
if Danbooru.config.new_relic_license_key.present?
|
||||
require "new_relic/control"
|
||||
|
||||
# https://github.com/newrelic/newrelic-ruby-agent/blob/1ef4082fe97fd19aeccb3f392a44ef3becae66d3/lib/newrelic_rpm.rb#L40
|
||||
# https://github.com/newrelic/newrelic-ruby-agent/blob/1ef4082fe97fd19aeccb3f392a44ef3becae66d3/lib/new_relic/agent.rb#L349
|
||||
NewRelic::Control.instance.init_plugin(
|
||||
app_name: Danbooru.config.canonical_app_name,
|
||||
license_key: Danbooru.config.new_relic_license_key,
|
||||
log_level: Danbooru.config.debug_mode ? "debug" : "error",
|
||||
log: Rails.logger,
|
||||
"rake.tasks": ["maintenance:.*"],
|
||||
config: Rails.application.config,
|
||||
)
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
# Ensure the agent is started using Unicorn.
|
||||
# This is needed when using Unicorn and preload_app is not set to true.
|
||||
# See https://newrelic.com/docs/ruby/no-data-with-unicorn
|
||||
if defined? ::NewRelic
|
||||
::NewRelic::Agent.manual_start
|
||||
::NewRelic::Agent.after_fork(:force_reconnect => true)
|
||||
end
|
||||
Reference in New Issue
Block a user