heroku-forward 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.md +1 -1
- data/README.md +32 -2
- data/lib/heroku/forward/backends/base.rb +27 -0
- data/lib/heroku/forward/backends/puma.rb +50 -0
- data/lib/heroku/forward/backends/thin.rb +3 -25
- data/lib/heroku/forward/backends/unicorn.rb +4 -21
- data/lib/heroku/forward/proxy/server.rb +1 -1
- data/lib/heroku/forward/version.rb +1 -1
- metadata +22 -4
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Heroku::Forward [](https://travis-ci.org/dblock/heroku-forward)
|
1
|
+
Heroku::Forward [](https://travis-ci.org/dblock/heroku-forward) [](https://codeclimate.com/repos/51fa634ec7f3a32cbd015aea/feed)
|
2
2
|
===============
|
3
3
|
|
4
4
|
Beat Heroku's 60 seconds timeout with a proxy.
|
@@ -52,6 +52,12 @@ proxy.forward!
|
|
52
52
|
|
53
53
|
This sets up a proxy on the port requested by Heroku and runs your application with [Thin](http://code.macournoyer.com/thin). Other back-ends are also supported, see below.
|
54
54
|
|
55
|
+
Add the following line to `config/development.rb` to see Rails logger output on `STDOUT`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
config.middleware.use Rails::Rack::LogTailer
|
59
|
+
```
|
60
|
+
|
55
61
|
Foreman
|
56
62
|
-------
|
57
63
|
|
@@ -153,6 +159,30 @@ proxy = Heroku::Forward::Proxy::Server.new(backend, host: '0.0.0.0', port: port)
|
|
153
159
|
proxy.forward!
|
154
160
|
```
|
155
161
|
|
162
|
+
### Puma
|
163
|
+
|
164
|
+
For more information about Puma see [http://puma.io](http://puma.io/).
|
165
|
+
|
166
|
+
The Puma back-end supports the following options.
|
167
|
+
|
168
|
+
* **application**: application to load
|
169
|
+
* **env**: environment, eg. `:development`
|
170
|
+
* **socket**: socket, eg. `/tmp/puma.sock`
|
171
|
+
* **config_file**: Puma configuration file
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
require 'heroku-forward'
|
175
|
+
require 'heroku/forward/backends/puma'
|
176
|
+
|
177
|
+
application = File.expand_path('../my_app.ru', __FILE__)
|
178
|
+
config_file = File.expand_path('../config/puma.rb', __FILE__)
|
179
|
+
backend = Heroku::Forward::Backends::Puma.new(application: application, env: env, config_file: config_file)
|
180
|
+
proxy = Heroku::Forward::Proxy::Server.new(backend, host: '0.0.0.0', port: port)
|
181
|
+
proxy.forward!
|
182
|
+
```
|
183
|
+
|
184
|
+
Note that heroku-forward does not currently run on JRuby, see [em-proxy#39](https://github.com/igrigorik/em-proxy/issues/39) for details.
|
185
|
+
|
156
186
|
Fail-Safe
|
157
187
|
---------
|
158
188
|
|
@@ -178,4 +208,4 @@ Copyright and License
|
|
178
208
|
|
179
209
|
MIT License, see [LICENSE](http://github.com/dblock/heroku-forward/raw/master/LICENSE.md) for details.
|
180
210
|
|
181
|
-
(c) 2012 [Daniel Doubrovkine](http://github.com/dblock), [
|
211
|
+
(c) 2012-2013 [Daniel Doubrovkine](http://github.com/dblock), [Artsy](http://artsy.github.com)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Heroku
|
2
|
+
module Forward
|
3
|
+
module Backends
|
4
|
+
class Base
|
5
|
+
attr_accessor :application, :socket, :environment, :pid
|
6
|
+
|
7
|
+
def terminate!
|
8
|
+
return false unless spawned?
|
9
|
+
Process.kill 'QUIT', @pid
|
10
|
+
@spawned = false
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def spawned?
|
15
|
+
!!@spawned
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def check!
|
21
|
+
raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
|
22
|
+
raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'heroku/forward/backends/base'
|
2
|
+
|
3
|
+
module Heroku
|
4
|
+
module Forward
|
5
|
+
module Backends
|
6
|
+
class Puma < Base
|
7
|
+
attr_accessor :config_file
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@application = options[:application]
|
11
|
+
@socket = options[:socket] || Heroku::Forward::Utils::Dir.tmp_filename('puma-', '.sock')
|
12
|
+
@env = options[:env] || 'development'
|
13
|
+
@config_file = options[:config_file]
|
14
|
+
end
|
15
|
+
|
16
|
+
def spawn!
|
17
|
+
return false if spawned?
|
18
|
+
check!
|
19
|
+
|
20
|
+
args = ['puma']
|
21
|
+
args.push '--environment', @env
|
22
|
+
args.push '--config', @config_file if @config_file
|
23
|
+
args.push '--bind', "unix://#{@socket}"
|
24
|
+
args.push @application
|
25
|
+
|
26
|
+
@pid = Spoon.spawnp(*args)
|
27
|
+
@spawned = true
|
28
|
+
end
|
29
|
+
|
30
|
+
def terminate!
|
31
|
+
return false unless spawned?
|
32
|
+
Process.kill 'QUIT', @pid
|
33
|
+
@spawned = false
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def spawned?
|
38
|
+
!!@spawned
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def check!
|
44
|
+
raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
|
45
|
+
raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,12 +1,9 @@
|
|
1
|
+
require 'heroku/forward/backends/base'
|
2
|
+
|
1
3
|
module Heroku
|
2
4
|
module Forward
|
3
5
|
module Backends
|
4
|
-
class Thin
|
5
|
-
attr_accessor :application
|
6
|
-
attr_accessor :socket
|
7
|
-
attr_accessor :environment
|
8
|
-
attr_accessor :pid
|
9
|
-
|
6
|
+
class Thin < Base
|
10
7
|
attr_accessor :ssl
|
11
8
|
attr_accessor :ssl_key_file
|
12
9
|
attr_accessor :ssl_cert_file
|
@@ -48,25 +45,6 @@ module Heroku
|
|
48
45
|
@pid = Spoon.spawnp(* spawn_with)
|
49
46
|
@spawned = true
|
50
47
|
end
|
51
|
-
|
52
|
-
def terminate!
|
53
|
-
return false unless spawned?
|
54
|
-
Process.kill 'QUIT', @pid
|
55
|
-
@spawned = false
|
56
|
-
true
|
57
|
-
end
|
58
|
-
|
59
|
-
def spawned?
|
60
|
-
!! @spawned
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def check!
|
66
|
-
raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
|
67
|
-
raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
|
68
|
-
end
|
69
|
-
|
70
48
|
end
|
71
49
|
end
|
72
50
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'heroku/forward/backends/base'
|
2
|
+
|
1
3
|
module Heroku
|
2
4
|
module Forward
|
3
5
|
module Backends
|
4
|
-
class Unicorn
|
5
|
-
attr_accessor :
|
6
|
+
class Unicorn < Base
|
7
|
+
attr_accessor :config_file
|
6
8
|
|
7
9
|
def initialize(options = {})
|
8
10
|
@application = options[:application]
|
@@ -24,25 +26,6 @@ module Heroku
|
|
24
26
|
@pid = Spoon.spawnp(*args)
|
25
27
|
@spawned = true
|
26
28
|
end
|
27
|
-
|
28
|
-
def terminate!
|
29
|
-
return false unless spawned?
|
30
|
-
Process.kill 'QUIT', @pid
|
31
|
-
@spawned = false
|
32
|
-
true
|
33
|
-
end
|
34
|
-
|
35
|
-
def spawned?
|
36
|
-
!!@spawned
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def check!
|
42
|
-
raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
|
43
|
-
raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
|
44
|
-
end
|
45
|
-
|
46
29
|
end
|
47
30
|
end
|
48
31
|
end
|
@@ -84,7 +84,7 @@ module Heroku
|
|
84
84
|
@start = nil
|
85
85
|
end
|
86
86
|
rescue RuntimeError => e
|
87
|
-
raise BackendFailedToStartError.new if @retries <= 0
|
87
|
+
raise Heroku::Forward::Errors::BackendFailedToStartError.new if @retries <= 0
|
88
88
|
logger.warn "#{e.message}, #{retries} #{retries == 1 ? 'retry' : 'retries'} left." if logger
|
89
89
|
@retries -= 1
|
90
90
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-forward
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-proxy
|
@@ -171,6 +171,22 @@ dependencies:
|
|
171
171
|
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '4.5'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: puma
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ~>
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '1.6'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ~>
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '1.6'
|
174
190
|
- !ruby/object:Gem::Dependency
|
175
191
|
name: em-http-request
|
176
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,6 +214,8 @@ files:
|
|
198
214
|
- lib/heroku-forward.rb
|
199
215
|
- lib/heroku/forward.rb
|
200
216
|
- lib/heroku/forward/backends.rb
|
217
|
+
- lib/heroku/forward/backends/base.rb
|
218
|
+
- lib/heroku/forward/backends/puma.rb
|
201
219
|
- lib/heroku/forward/backends/thin.rb
|
202
220
|
- lib/heroku/forward/backends/unicorn.rb
|
203
221
|
- lib/heroku/forward/config/locales/en.yml
|
@@ -227,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
245
|
version: '0'
|
228
246
|
segments:
|
229
247
|
- 0
|
230
|
-
hash:
|
248
|
+
hash: 470077483543450957
|
231
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
250
|
none: false
|
233
251
|
requirements:
|
@@ -236,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
254
|
version: '0'
|
237
255
|
requirements: []
|
238
256
|
rubyforge_project:
|
239
|
-
rubygems_version: 1.8.
|
257
|
+
rubygems_version: 1.8.25
|
240
258
|
signing_key:
|
241
259
|
specification_version: 3
|
242
260
|
summary: Beat Heroku's 60s boot timeout with a forward proxy.
|