From f3835ab61e63116ee8a48ed3c9ec8a0a437f6da8 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Fri, 8 Sep 2017 12:04:37 -0700 Subject: [PATCH] Raise an exception after 3 attempts --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 183a9d3..6397ed9 100644 --- a/Rakefile +++ b/Rakefile @@ -7,10 +7,11 @@ Rails.application.load_tasks if ENV['IN_DOCKER'] def wait_for_db_container - loop do + 3.times do return if connect_to_db sleep 1 end + raise RuntimeError.new 'Could not establish connection to postgres in 3 attempts' end def connect_to_db