Skip to content

Commit ec4feae

Browse files
committed
Merge pull request #365 from alphagov/fix-app-signal
Improve reliability of AppSignal initialization process
2 parents af8299f + 6caec23 commit ec4feae

5 files changed

Lines changed: 13 additions & 2 deletions

File tree

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,6 @@ DEPENDENCIES
334334
webmock
335335
whenever
336336
will_paginate
337+
338+
BUNDLED WITH
339+
1.10.4

bin/delayed_job

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
44
require 'delayed/command'
55

6+
# Restart the AppSignal thread that we stopped in the initializer
7+
Appsignal.agent.start_thread if defined?(Appsignal) && Appsignal.config.active?
8+
69
Delayed::Command.new(ARGV).daemonize

config/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Application < Rails::Application
4545

4646
config.action_dispatch.default_headers.merge!('X-UA-Compatible' => 'IE=edge')
4747

48-
# Needed as Rails does not eager load app/jobs/concerns by default
49-
config.eager_load_paths += [Rails.root.join('app/jobs/concerns')]
48+
# Needed as Rails does not add app/jobs/concerns to the load path
49+
config.paths.add 'app/jobs/concerns', eager_load: true
5050
end
5151
end

config/initializers/appsignal.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Stop the AppSignal agent thread and restart it when the workers are forked
2+
Appsignal.agent.stop_thread if defined?(Appsignal) && Appsignal.config.active?

config/puma.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@
2424
# Worker specific setup for Rails 4.1+
2525
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
2626
ActiveRecord::Base.establish_connection
27+
28+
# Let AppSignal know that a worker process has been forked
29+
Appsignal.agent.forked! if defined?(Appsignal) && Appsignal.config.active?
2730
end

0 commit comments

Comments
 (0)