DEV: Add rake task to check that the DB can be accessed ()

This commit is contained in:
Daniel Waterworth 2021-09-09 14:42:10 -05:00 committed by GitHub
parent 789613fe51
commit 05c356f7c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions
lib/tasks

View File

@ -545,3 +545,15 @@ task 'db:rebuild_indexes' => 'environment' do
Discourse.disable_readonly_mode
end
end
desc 'Check that the DB can be accessed'
task 'db:status:json' do
begin
Rake::Task['environment'].invoke
DB.query('SELECT 1')
rescue
puts({ status: 'error' }.to_json)
else
puts({ status: 'ok' }.to_json)
end
end