2023-05-24 19:55:40 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative '../../../config/boot'
|
|
|
|
require_relative '../../../config/environment'
|
|
|
|
|
|
|
|
require 'thor'
|
2024-01-04 01:12:56 +11:00
|
|
|
require 'pastel'
|
2023-06-01 22:31:24 +10:00
|
|
|
require_relative 'progress_helper'
|
2023-05-24 19:55:40 +10:00
|
|
|
|
|
|
|
module Mastodon
|
|
|
|
module CLI
|
|
|
|
class Base < Thor
|
2023-06-01 22:31:24 +10:00
|
|
|
include ProgressHelper
|
2023-05-24 19:55:40 +10:00
|
|
|
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
2023-06-01 22:31:24 +10:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2024-01-26 19:53:44 +11:00
|
|
|
def fail_with_message(message)
|
|
|
|
raise Thor::Error, message
|
|
|
|
end
|
|
|
|
|
2023-06-01 22:31:24 +10:00
|
|
|
def pastel
|
|
|
|
@pastel ||= Pastel.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def dry_run?
|
|
|
|
options[:dry_run]
|
|
|
|
end
|
|
|
|
|
|
|
|
def dry_run_mode_suffix
|
|
|
|
dry_run? ? ' (DRY RUN)' : ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_connection_pools!
|
|
|
|
ActiveRecord::Base.establish_connection(
|
|
|
|
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first.configuration_hash
|
|
|
|
.dup
|
|
|
|
.tap { |config| config['pool'] = options[:concurrency] + 1 }
|
|
|
|
)
|
|
|
|
RedisConfiguration.establish_pool(options[:concurrency])
|
|
|
|
end
|
2023-05-24 19:55:40 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|