diff --git a/config/database.yml b/config/database.yml index d365fc66..212d9cdd 100644 --- a/config/database.yml +++ b/config/database.yml @@ -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 diff --git a/lib/tasks/boot.rake b/lib/tasks/boot.rake index 2ef2693f..0a3dadc1 100644 --- a/lib/tasks/boot.rake +++ b/lib/tasks/boot.rake @@ -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