Created
March 30, 2017 23:19
-
-
Save frank184/fb81301b543187a2502ecd9887a3096a to your computer and use it in GitHub Desktop.
Wait for DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
def try_connection | |
TCPSocket.new(ENV['DB_HOST'], 3306) | |
rescue Errno::ECONNREFUSED | |
false | |
else | |
true | |
end | |
until try_connection | |
puts "Waiting for database..." | |
sleep 1 | |
end | |
puts "Database is running!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment