Handle CLI failure exit status at the top-level script (#28322)

This commit is contained in:
Matt Jankowski 2024-01-26 03:53:44 -05:00 committed by GitHub
parent 881e8c113c
commit 0e0a94f483
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 150 additions and 320 deletions

View file

@ -199,26 +199,24 @@ module Mastodon::CLI
def verify_schema_version!
if migrator_version < MIN_SUPPORTED_VERSION
say 'Your version of the database schema is too old and is not supported by this script.', :red
say 'Please update to at least Mastodon 3.0.0 before running this script.', :red
exit(1)
fail_with_message <<~ERROR
Your version of the database schema is too old and is not supported by this script.
Please update to at least Mastodon 3.0.0 before running this script.
ERROR
elsif migrator_version > MAX_SUPPORTED_VERSION
say 'Your version of the database schema is more recent than this script, this may cause unexpected errors.', :yellow
exit(1) unless yes?('Continue anyway? (Yes/No)')
fail_with_message 'Stopping maintenance script because data is more recent than script version.' unless yes?('Continue anyway? (Yes/No)')
end
end
def verify_sidekiq_not_active!
if Sidekiq::ProcessSet.new.any?
say 'It seems Sidekiq is running. All Mastodon processes need to be stopped when using this script.', :red
exit(1)
end
fail_with_message 'It seems Sidekiq is running. All Mastodon processes need to be stopped when using this script.' if Sidekiq::ProcessSet.new.any?
end
def verify_backup_warning!
say 'This task will take a long time to run and is potentially destructive.', :yellow
say 'Please make sure to stop Mastodon and have a backup.', :yellow
exit(1) unless yes?('Continue? (Yes/No)')
fail_with_message 'Maintenance process stopped.' unless yes?('Continue? (Yes/No)')
end
def deduplicate_accounts!