elb-health-check 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15b2067facf15e86d20ab108c164f5e2dceeb051
4
+ data.tar.gz: '09721984cc01e95d1d63b5c32ea4733c581307b1'
5
+ SHA512:
6
+ metadata.gz: 4f7f2493c0cba52591751335cdd1d8300bc464e6b926fd1fb045b2851c4eec16b3c94abb8e0f01ac3097973fb6249b9109fd6df46e2e0c8f6991508f8148106c
7
+ data.tar.gz: 7bd9948c2cf93035db51b6021259fb8a06a0190f8c7b3872f61ab2ff14f07a077381bbda42744692389c0fb249e060a7d253838fe0a3702f63123c5d9e7e067e
@@ -0,0 +1,15 @@
1
+ module ElbHealthCheck
2
+ mattr_accessor :uris, :checks
3
+
4
+ def self.configure
5
+ yield self
6
+ end
7
+
8
+ # Default config
9
+ self.uris = ['/health_check']
10
+ self.checks = %i(database)
11
+ end
12
+
13
+ require 'elb_health_check/middleware'
14
+ require 'elb_health_check/railtie'
15
+
@@ -0,0 +1,34 @@
1
+ module ElbHealthCheck
2
+ class Middleware
3
+ attr_accessor :app
4
+
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ if ElbHealthCheck.uris.include?(env['PATH_INFO'])
11
+
12
+ checks = ElbHealthCheck.checks.map { |check| send("#{check}?") }
13
+
14
+ if checks.include?(false)
15
+ return [500, {}, ['FAILED']]
16
+ else
17
+ return [200, {}, ['OK']]
18
+ end
19
+ end
20
+
21
+ app.call(env)
22
+ end
23
+
24
+ private
25
+
26
+ def database?
27
+ if defined?(ActiveRecord)
28
+ ActiveRecord::Base.connection.active?
29
+ else
30
+ true
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+
3
+ module ElbHealthCheck
4
+ class Railtie < ::Rails::Railtie
5
+ config.app_middleware.insert_before 0, ElbHealthCheck::Middleware
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ElbHealthCheck
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elb-health-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joergen Dahlke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Provides an URL for to check the health of the application
56
+ email:
57
+ - joergen.dahlke@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/elb-health-check.rb
63
+ - lib/elb_health_check/middleware.rb
64
+ - lib/elb_health_check/railtie.rb
65
+ - lib/elb_health_check/version.rb
66
+ homepage: https://github.com/jdahlke/elb_health_check
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project: elb-health-check
86
+ rubygems_version: 2.5.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Simple healthcheck for Rails apps
90
+ test_files: []