2023-05-24 09:55:40 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative '../../../config/boot'
|
|
|
|
require_relative '../../../config/environment'
|
|
|
|
|
|
|
|
require 'thor'
|
2024-01-03 14:12:56 +00:00
|
|
|
require 'pastel'
|
2023-06-01 12:31:24 +00:00
|
|
|
require_relative 'progress_helper'
|
2023-05-24 09:55:40 +00:00
|
|
|
|
|
|
|
module Mastodon
|
|
|
|
module CLI
|
|
|
|
class Base < Thor
|
2023-06-01 12:31:24 +00:00
|
|
|
include ProgressHelper
|
2023-05-24 09:55:40 +00:00
|
|
|
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
2023-06-01 12:31:24 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2024-01-26 08:53:44 +00:00
|
|
|
def fail_with_message(message)
|
|
|
|
raise Thor::Error, message
|
|
|
|
end
|
|
|
|
|
2023-06-01 12:31:24 +00: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 09:55:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|