From 27f5a59735bf98ca746fc694c5beb74ade18b0c8 Mon Sep 17 00:00:00 2001 From: Michal Cichra Date: Mon, 22 Oct 2018 14:49:54 +0200 Subject: [PATCH 1/2] [rake] print information about connected database --- lib/tasks/boot.rake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From 61ac62aec1abbf3203ea18931cc4f846f03b6e95 Mon Sep 17 00:00:00 2001 From: Michal Cichra Date: Tue, 23 Oct 2018 08:32:08 +0200 Subject: [PATCH 2/2] [db] tune connection timeout --- config/database.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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