Skip to content

Commit

Permalink
Merge pull request #113 from 3scale/rake-boot-db
Browse files Browse the repository at this point in the history
[rake] print information about connected database
  • Loading branch information
mikz authored Oct 23, 2018
2 parents c1e1768 + 681b406 commit 0e0365b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS"){ 5 }.to_i * 4 %>
timeout: 5000
connect_timeout: 5
variables:
statement_timeout: 5000
statement_timeout: 5000 # ms

development:
<<: *default
Expand Down
5 changes: 4 additions & 1 deletion lib/tasks/boot.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
namespace :boot do
desc "Return failure in case database is not ready"
task db: :environment do
spec = ApplicationRecord.connection_config
url = URI::Generic.build(scheme: spec[:adapter], host: spec[:host], path: "/#{spec[:database]}", port: spec[:port])
begin
ApplicationRecord.retrieve_connection
puts "connected to #{url}"
rescue => error
warn error
warn "failed to connect to: #{url}", error
exit ApplicationRecord.connected?
end
end
Expand Down

0 comments on commit 0e0365b

Please sign in to comment.