Skip to content

Commit

Permalink
Improve error handling in mastodon:setup task (mastodon#21464)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Oct 23, 2023
1 parent 99f2534 commit 44edf3a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/tasks/mastodon.rake
Expand Up @@ -17,6 +17,8 @@ namespace :mastodon do
ENV.delete('SIDEKIQ_REDIS_URL')

begin
errors = false

prompt.say('Your instance is identified by its domain name. Changing it afterward will break things.')
env['LOCAL_DOMAIN'] = prompt.ask('Domain name:') do |q|
q.required true
Expand Down Expand Up @@ -95,7 +97,11 @@ namespace :mastodon do
rescue => e
prompt.error 'Database connection could not be established with this configuration, try again.'
prompt.error e.message
break unless prompt.yes?('Try again?')
unless prompt.yes?('Try again?')
return prompt.warn 'Nothing saved. Bye!' unless prompt.yes?('Continue anyway?')
errors = true
break
end
end
end

Expand Down Expand Up @@ -135,7 +141,11 @@ namespace :mastodon do
rescue => e
prompt.error 'Redis connection could not be established with this configuration, try again.'
prompt.error e.message
break unless prompt.yes?('Try again?')
unless prompt.yes?('Try again?')
return prompt.warn 'Nothing saved. Bye!' unless prompt.yes?('Continue anyway?')
errors = true
break
end
end
end

Expand Down Expand Up @@ -420,7 +430,11 @@ namespace :mastodon do
rescue => e
prompt.error 'E-mail could not be sent with this configuration, try again.'
prompt.error e.message
break unless prompt.yes?('Try again?')
unless prompt.yes?('Try again?')
return prompt.warn 'Nothing saved. Bye!' unless prompt.yes?('Continue anyway?')
errors = true
break
end
end
end

Expand Down Expand Up @@ -466,6 +480,7 @@ namespace :mastodon do
prompt.ok 'Done!'
else
prompt.error 'That failed! Perhaps your configuration is not right'
errors = true
end
end

Expand All @@ -482,12 +497,17 @@ namespace :mastodon do
prompt.say 'Done!'
else
prompt.error 'That failed! Maybe you need swap space?'
errors = true
end
end
end

prompt.say "\n"
prompt.ok 'All done! You can now power on the Mastodon server 🐘'
if errors
prompt.warn 'Your Mastodon server is set up, but there were some errors along the way, you may have to fix them.'
else
prompt.ok 'All done! You can now power on the Mastodon server 🐘'
end
prompt.say "\n"

if db_connection_works && prompt.yes?('Do you want to create an admin user straight away?')
Expand Down

0 comments on commit 44edf3a

Please sign in to comment.