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