Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip starting Judoscale reporter on rails runner process #217

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions judoscale-rails/lib/judoscale/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module Rails
class Railtie < ::Rails::Railtie
include Judoscale::Logger

def in_rails_console?
# This is gross, but we can't find a more reliable way to detect if we're in a Rails console.
caller.any? { |call| call.include?("console_command.rb") }
def in_rails_console_or_runner?
# This is gross, but we can't find a more reliable way to detect if we're in a Rails console/runner.
caller.any? { |call| call.include?("console_command.rb") || call.include?("runner_command.rb") }
end

def in_rake_task?(task_regex)
Expand All @@ -36,8 +36,8 @@ def judoscale_config
end

config.after_initialize do
if in_rails_console?
logger.debug "No reporting since we're in a Rails console"
if in_rails_console_or_runner?
logger.debug "No reporting since we're in a Rails console or runner process"
elsif in_rake_task?(/assets:|db:/)
logger.debug "No reporting since we're in a build process"
elsif judoscale_config.start_reporter_after_initialize
Expand Down
Loading