wait_pg 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/wait_pg +31 -0
  3. metadata +60 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 041add53e7b155106cb62985c27f721cba0e0b97
4
+ data.tar.gz: 62ddf5ac0f6b8dc178dcbb25790bbeaf6b0876f0
5
+ SHA512:
6
+ metadata.gz: ebabb80948fa11f2fee00eab77a8922c2cd60de0279f7f30fac18f99fe234615bc7eae1fd93445312326c286fdc30fcd8dc77fb84f885246d48deeda99d18a17
7
+ data.tar.gz: 631d74a773d568afed5c38ff75cc4ebdcd76d998772c2d6cc361182dc0c11b9230e1f0ac896aa38c8becef7ee71d29b8c9729bb2a64d12eecb5d5beebd761051
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'erb'
3
+ require 'pg'
4
+ require 'yaml'
5
+
6
+ # Wait for 60 seconds for a connection
7
+ retries = 30
8
+ interval = 2
9
+
10
+ rails_env = ENV.fetch('RAILS_ENV') { 'development' }
11
+ database_yml = YAML.load(ERB.new(File.read(File.expand_path('./config/database.yml'))).result)[rails_env]
12
+
13
+ connection_options = {
14
+ user: database_yml['username'],
15
+ host: database_yml['host'],
16
+ password: database_yml['password'],
17
+ port: database_yml['port'],
18
+ }
19
+
20
+ if database_yml['database_url'] && !database_yml['database_url'].empty?
21
+ connection_options = database_yml['database_url']
22
+ end
23
+
24
+ puts 'Waiting for PostgreSQL...'
25
+
26
+ retries.times do
27
+ exit 0 if PG::PQPING_OK == PG::Connection.ping(connection_options)
28
+ sleep interval
29
+ end
30
+
31
+ exit 1
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wait_pg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - mroutis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pg
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - outis@civica.digital
30
+ executables:
31
+ - wait_pg
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/wait_pg
36
+ homepage: https://github.com/civica-digital/wait_pg
37
+ licenses:
38
+ - Unlicense
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.6.11
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Add a binary that waits for a PostgreSQL connection in a Ruby on Rails app.
60
+ test_files: []