Skip to content

Commit

Permalink
Merge pull request #365 from alphagov/fix-app-signal
Browse files Browse the repository at this point in the history
Improve reliability of AppSignal initialization process
  • Loading branch information
alanth committed Jul 31, 2015
2 parents af8299f + 6caec23 commit ec4feae
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -334,3 +334,6 @@ DEPENDENCIES
webmock
whenever
will_paginate

BUNDLED WITH
1.10.4
3 changes: 3 additions & 0 deletions bin/delayed_job
Expand Up @@ -3,4 +3,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'

# Restart the AppSignal thread that we stopped in the initializer
Appsignal.agent.start_thread if defined?(Appsignal) && Appsignal.config.active?

Delayed::Command.new(ARGV).daemonize
4 changes: 2 additions & 2 deletions config/application.rb
Expand Up @@ -45,7 +45,7 @@ class Application < Rails::Application

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

# Needed as Rails does not eager load app/jobs/concerns by default
config.eager_load_paths += [Rails.root.join('app/jobs/concerns')]
# Needed as Rails does not add app/jobs/concerns to the load path
config.paths.add 'app/jobs/concerns', eager_load: true
end
end
2 changes: 2 additions & 0 deletions config/initializers/appsignal.rb
@@ -0,0 +1,2 @@
# Stop the AppSignal agent thread and restart it when the workers are forked
Appsignal.agent.stop_thread if defined?(Appsignal) && Appsignal.config.active?
3 changes: 3 additions & 0 deletions config/puma.rb
Expand Up @@ -24,4 +24,7 @@
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection

# Let AppSignal know that a worker process has been forked
Appsignal.agent.forked! if defined?(Appsignal) && Appsignal.config.active?
end

0 comments on commit ec4feae

Please sign in to comment.