base.rb 893 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. require_relative '../../../config/boot'
  3. require_relative '../../../config/environment'
  4. require 'thor'
  5. require_relative 'progress_helper'
  6. module Mastodon
  7. module CLI
  8. class Base < Thor
  9. include ProgressHelper
  10. def self.exit_on_failure?
  11. true
  12. end
  13. private
  14. def pastel
  15. @pastel ||= Pastel.new
  16. end
  17. def dry_run?
  18. options[:dry_run]
  19. end
  20. def dry_run_mode_suffix
  21. dry_run? ? ' (DRY RUN)' : ''
  22. end
  23. def reset_connection_pools!
  24. ActiveRecord::Base.establish_connection(
  25. ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first.configuration_hash
  26. .dup
  27. .tap { |config| config['pool'] = options[:concurrency] + 1 }
  28. )
  29. RedisConfiguration.establish_pool(options[:concurrency])
  30. end
  31. end
  32. end
  33. end