elastic_beans 0.13.0.alpha5 → 0.13.0.alpha6

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
2
  SHA1:
3
- metadata.gz: 1afb81d4fa7f5f42059df586f24b1e39a4306f2e
4
- data.tar.gz: bf4b9d6263e6e75e76fd1fb02ac3240193712f61
3
+ metadata.gz: 664c74c9be1710fc97174af435e1cc4e67db6c06
4
+ data.tar.gz: eb6e2d1028c9a5ca81d0ec6295dd127255f567a5
5
5
  SHA512:
6
- metadata.gz: c82526896458dd23dff5d494c204b3effde9567f0a752b2bf08800cc7e25017b83c91e01dbfe2399a293f0d763378b2cc3df6249732d2972bac590ca19aabe96
7
- data.tar.gz: a5b9fc5746ed2aec887b38fa05212dc7e29bb79c4e7851b65f8405095087c77479b31cdaab069b82f5f6d3fed35ea065dfbaff724de8f32836d3ae30efbcb284
6
+ metadata.gz: 7890ae4cbe0d96b740cc3348425ce17a49e64766023a2693977198c3f34948803fbf1dd8e7d6fc4bfd779ee0405daabbe5d1dd1fc11fc2eb24f8061af13233ca
7
+ data.tar.gz: dd413fc4e2ffb0b9a74da493fc87918352cc24d643d58491d3cedefd3625bd19ab19f8903b3cd66fc19c2cb24e26fd52448912af5bcaa02cfd8568664f733f0c
data/README.md CHANGED
@@ -79,6 +79,25 @@ Elastic Beans exposes the classes it uses to manage Elastic Beanstalk so you can
79
79
 
80
80
  AWS SDK clients must be passed into Elastic Beans constructors.
81
81
 
82
+ ### Health check
83
+
84
+ Elastic Beanstalk worker environments have an internal health check performed on the instance that does not support HTTPS.
85
+ Elastic Beans includes a health check middleware to respond to `GET /` requests originating from `localhost`.
86
+
87
+ In `config/initializers/elastic_beans.rb`, add the middleware into your stack, below forcing HTTPS:
88
+
89
+ require "elastic_beans/rack/health_check"
90
+
91
+ if Rails.configuration.force_ssl
92
+ Rails.configuration.middleware.insert_before(
93
+ ActionDispatch::SSL,
94
+ ElasticBeans::Rack::HealthCheck,
95
+ logger: Rails.logger,
96
+ )
97
+ else
98
+ Rails.configuration.middleware.use(ElasticBeans::Rack::HealthCheck, logger: Rails.logger)
99
+ end
100
+
82
101
  ### Periodic tasks
83
102
 
84
103
  Elastic Beanstalk [supports periodic tasks][periodic] by sending a POST request to an endpoint of your application.
@@ -7,7 +7,7 @@ module ElasticBeans
7
7
  # ElasticBeans::Application#enqueue_command.
8
8
  # Load it in your Rails application so the "scheduler" environment enqueues commands for execution.
9
9
  #
10
- # Only accepts localhost requests from `aws-sqsd`.
10
+ # Only accepts localhost requests from +aws-sqsd+.
11
11
  class Exec
12
12
  FAILURE = ['500', {'Content-type' => 'text/plain'}, [""]]
13
13
  SUCCESS = ['200', {'Content-type' => 'text/plain'}, [""]]
@@ -0,0 +1,43 @@
1
+ require "logger"
2
+ require "action_dispatch"
3
+
4
+ module ElasticBeans
5
+ module Rack
6
+ # A middleware that returns 200 OK to +aws-sqsd+'s health check, which does not support HTTPS.
7
+ # Load it in your Rails application so non-webserver environments are considered healthy.
8
+ #
9
+ # Only accepts localhost requests to +GET+ the root path.
10
+ class HealthCheck
11
+ SUCCESS = ['200', {'Content-type' => 'text/plain'}, [""]]
12
+
13
+ def initialize(app, args={})
14
+ @app = app
15
+ @logger = args[:logger] || Logger.new("/dev/null")
16
+ end
17
+
18
+ def call(env)
19
+ request = ActionDispatch::Request.new(env)
20
+ if enabled? && health_request?(request)
21
+ logger.debug { "[elastic_beans] Healthy response to local client" }
22
+ return SUCCESS
23
+ end
24
+
25
+ logger.debug { "[elastic_beans] skipped health request: #{request.path}" }
26
+ app.call(env)
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :app, :logger
32
+
33
+ def enabled?
34
+ worker_disabled = ENV['DISABLE_SQS_CONSUMER'] || 'false'
35
+ worker_disabled == 'false'
36
+ end
37
+
38
+ def health_request?(request)
39
+ request.local? && request.method == 'GET' && request.path == '/'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.13.0.alpha5"
2
+ VERSION = "0.13.0.alpha6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.alpha5
4
+ version: 0.13.0.alpha6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -232,6 +232,7 @@ files:
232
232
  - lib/elastic_beans/exec/sqs_consumer.rb
233
233
  - lib/elastic_beans/network.rb
234
234
  - lib/elastic_beans/rack/exec.rb
235
+ - lib/elastic_beans/rack/health_check.rb
235
236
  - lib/elastic_beans/scheduler/ebextension.yml
236
237
  - lib/elastic_beans/ssh.rb
237
238
  - lib/elastic_beans/ui.rb