2023-05-24 12:55:40 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative '../../../config/boot'
|
|
|
|
require_relative '../../../config/environment'
|
|
|
|
|
|
|
|
require 'thor'
|
2023-06-01 15:31:24 +03:00
|
|
|
require_relative 'progress_helper'
|
2023-05-24 12:55:40 +03:00
|
|
|
|
|
|
|
module Mastodon
|
|
|
|
module CLI
|
|
|
|
class Base < Thor
|
2023-06-01 15:31:24 +03:00
|
|
|
include ProgressHelper
|
2023-05-24 12:55:40 +03:00
|
|
|
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
2023-06-01 15:31:24 +03:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
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 12:55:40 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|