philae 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 70ea14a62ae9cc0750b373c086a56f734bef85ca
4
- data.tar.gz: 95205429ab4bce4a145e504d281bc7b0ced29e63
2
+ SHA256:
3
+ metadata.gz: 98c6b24b9ffa3987fffbb4a47f404e8d20e728663be1dd3a6953972bfab2a7d6
4
+ data.tar.gz: f646a2b162c96cf3eced95b894f75ab74e64a13fb9dc40618ebf6757a721a068
5
5
  SHA512:
6
- metadata.gz: 8b97f1c5d6b4b22cbc345ca3bc136bcdfac9508c7fd94dfb557fbc8dcfc4b661987d846634f7513d453314c365f43dcd07a96adf9030c35835a8bb56bcc3cb73
7
- data.tar.gz: b8e42c84fe8694b2b279c63c08b7c0c5923f925bc62f3d36f7955a3502e61157a299bf148dc6bfb97f8075ef8a860401cfbe8a2fb70e5a7ec4423621ac39d392
6
+ metadata.gz: c0a665aee100b59fa4057f1cb688aebf8fcf52282408142b3186d53da9e236522ad74c2945c26f0be66e38a377329cfb494863e24a85acde4f7ac72b4a7102e8
7
+ data.tar.gz: 8316c82012b480bb5cd6b43b2992a5b6e3712a78337031c51760903cc9d79a6962f71aeef5e1ed3a426a33c4d4ede4ddc0c99218c47835a5f881363cd4afd417
@@ -12,14 +12,14 @@ module Philae
12
12
 
13
13
  def check
14
14
  Docker.url = @endpoint
15
- Docker.options = @docker_options unless @docker_options.nil? # <3 Etienne
15
+ Docker.options = @docker_options if !@docker_options.nil?
16
16
  begin
17
17
  Docker::Container.all
18
18
  rescue
19
- return {healthy: false, comment: 'Unable to communicate with docker'}
19
+ return { healthy: false, comment: 'Unable to communicate with docker' }
20
20
  end
21
21
 
22
- { healthy: true, comment: '' }
22
+ return { healthy: true, comment: '' }
23
23
  end
24
24
  end
25
25
  end
@@ -48,7 +48,8 @@ module Philae
48
48
  rescue Exception => e
49
49
  return { healthy: false, comment: "Unable to contact etcd (#{e.message})" }
50
50
  end
51
- { healthy: true, comment: '' }
51
+
52
+ return { healthy: true, comment: '' }
52
53
  end
53
54
  end
54
55
  end
@@ -41,7 +41,8 @@ module Philae
41
41
  rescue => e
42
42
  return { healthy: false, comment: 'Unable to contact server', error: "#{e.class}: #{e.message}" }
43
43
  end
44
- { healthy: true, comment: '' }
44
+
45
+ return { healthy: true, comment: '' }
45
46
  end
46
47
  end
47
48
  end
@@ -20,7 +20,8 @@ module Philae
20
20
  rescue
21
21
  return { healthy: false, comment: 'Unable to contact mongo' }
22
22
  end
23
- { healthy: true, comment: '' }
23
+
24
+ return { healthy: true, comment: '' }
24
25
  end
25
26
  end
26
27
  end
@@ -0,0 +1,32 @@
1
+ require 'pg'
2
+
3
+ # Philae::PostgreSQLProbe tries to connect to the given connection string and
4
+ # ping the database. The connection string must be in the form
5
+ # `postgres://[username:password@]host1[:port1][/[database][?options]]`
6
+ module Philae
7
+ class PostgreSQLProbe
8
+ attr_reader :name
9
+
10
+ def initialize(name, connection_string)
11
+ @name = name
12
+ @connection_string = connection_string
13
+ end
14
+
15
+ def check
16
+ begin
17
+ res = PG::Connection.ping(@connection_string)
18
+ rescue
19
+ return { healthy: false, comment: 'Unable to contact PostgreSQL' }
20
+ end
21
+ return { healthy: true, comment: '' } if res == PG::PQPING_OK
22
+
23
+ # https://deveiate.org/code/pg/PG/Connection.html#method-c-ping
24
+ reasons = {
25
+ PG::PQPING_REJECT => 'server is alive but rejecting connections',
26
+ PG::PQPING_NO_RESPONSE => 'could not establish connection',
27
+ PG::PQPING_NO_ATTEMPT => 'connection not attempted (bad params)',
28
+ }
29
+ return { healthy: false, comment: "Ping to PostgreSQL failed with the following reason: #{reasons[res]}" }
30
+ end
31
+ end
32
+ end
data/lib/philae/prober.rb CHANGED
@@ -18,10 +18,7 @@ module Philae
18
18
  probe[:healthy]
19
19
  end
20
20
 
21
- {
22
- healthy: global,
23
- probes: probes_status
24
- }
21
+ return { healthy: global, probes: probes_status }
25
22
  end
26
23
  end
27
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo@scalingo.com
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-06 00:00:00.000000000 Z
13
+ date: 2019-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: docker-api
@@ -27,19 +27,19 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.33'
29
29
  - !ruby/object:Gem::Dependency
30
- name: mongo
30
+ name: etcd
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '2.4'
35
+ version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.4'
42
+ version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: json
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -55,19 +55,19 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: '2.1'
57
57
  - !ruby/object:Gem::Dependency
58
- name: etcd
58
+ name: mongo
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: '2.4'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '2.4'
71
71
  description:
72
72
  email: hello@scalingo.com
73
73
  executables: []
@@ -80,6 +80,7 @@ files:
80
80
  - lib/philae/http_probe.rb
81
81
  - lib/philae/mongo_probe.rb
82
82
  - lib/philae/nsq_probe.rb
83
+ - lib/philae/pgsql_probe.rb
83
84
  - lib/philae/philae_probe.rb
84
85
  - lib/philae/prober.rb
85
86
  - lib/rack/philae_rack.rb
@@ -102,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubyforge_project:
106
- rubygems_version: 2.6.13
106
+ rubygems_version: 3.0.3
107
107
  signing_key:
108
108
  specification_version: 4
109
- summary: Provide an health check api
109
+ summary: Provide an health check API
110
110
  test_files: []