heroku-forward 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,3 +2,4 @@ require 'heroku/forward/version'
2
2
  require 'heroku/forward/errors'
3
3
  require 'heroku/forward/backends'
4
4
  require 'heroku/forward/proxy'
5
+ require 'heroku/forward/utils/dir'
@@ -22,7 +22,7 @@ module Heroku
22
22
  # ssl_verify: activated with ssl_verify
23
23
  def initialize(options = {})
24
24
  @application = options[:application]
25
- @socket = options[:socket] || new_socket
25
+ @socket = options[:socket] || Heroku::Forward::Utils::Dir.tmp_filename('thin-', '.sock')
26
26
  @env = options[:env] || :development
27
27
 
28
28
  @ssl = options[:ssl] || false
@@ -62,16 +62,10 @@ module Heroku
62
62
 
63
63
  private
64
64
 
65
- def new_socket
66
- Tempfile.open 'thin' do |file|
67
- return file.path
68
- end
69
- end
70
-
71
- def check!
72
- raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
73
- raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
74
- end
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
75
69
 
76
70
  end
77
71
  end
@@ -3,51 +3,46 @@ module Heroku
3
3
  module Backends
4
4
  class Unicorn
5
5
  attr_accessor :application, :socket, :environment, :pid, :config_file
6
-
6
+
7
7
  def initialize(options = {})
8
8
  @application = options[:application]
9
- @socket = options[:socket] || tmp_filename('unicorn', '.sock')
9
+ @socket = options[:socket] || Heroku::Forward::Utils::Dir.tmp_filename('unicorn-', '.sock')
10
10
  @env = options[:env] || 'development'
11
11
  @config_file = options[:config_file]
12
12
  end
13
-
13
+
14
14
  def spawn!
15
15
  return false if spawned?
16
16
  check!
17
-
17
+
18
18
  args = ['unicorn']
19
19
  args.push '--env', @env
20
20
  args.push '--config-file', @config_file if @config_file
21
21
  args.push '--listen', @socket
22
22
  args.push @application
23
-
23
+
24
24
  @pid = Spoon.spawnp(*args)
25
25
  @spawned = true
26
26
  end
27
-
27
+
28
28
  def terminate!
29
29
  return false unless spawned?
30
30
  Process.kill 'QUIT', @pid
31
31
  @spawned = false
32
32
  true
33
33
  end
34
-
34
+
35
35
  def spawned?
36
36
  !!@spawned
37
37
  end
38
-
38
+
39
39
  private
40
-
41
- # Borrowed from ruby 1.9's Dir::Tmpname.make_tmpname for 1.8.7-compatibility.
42
- def tmp_filename(prefix, suffix)
43
- File.join Dir.tmpdir, "#{prefix}#{Time.now.strftime("%Y%m%d")}-#{$$}-#{rand(0x100000000).to_s(36)}#{suffix}"
44
- end
45
-
40
+
46
41
  def check!
47
42
  raise Heroku::Forward::Errors::MissingBackendOptionError.new('application') unless @application && @application.length > 0
48
43
  raise Heroku::Forward::Errors::MissingBackendApplicationError.new(@application) unless File.exists?(@application)
49
44
  end
50
-
45
+
51
46
  end
52
47
  end
53
48
  end
@@ -0,0 +1,16 @@
1
+ module Heroku
2
+ module Forward
3
+ module Utils
4
+
5
+ module Dir
6
+
7
+ # Partially borrowed from ruby 1.9's Dir::Tmpname.make_tmpname for 1.8.7-compatibility.
8
+ def self.tmp_filename(prefix, suffix)
9
+ File.join ::Dir.tmpdir, "#{prefix}#{Time.now.strftime("%Y%m%d")}-#{$$}-#{rand(0x100000000).to_s(36)}#{suffix}"
10
+ end
11
+
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  module Forward
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  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.3.0
4
+ version: 0.3.1
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-24 00:00:00.000000000 Z
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-proxy
@@ -208,6 +208,7 @@ files:
208
208
  - lib/heroku/forward/errors/missing_backend_option_error.rb
209
209
  - lib/heroku/forward/proxy.rb
210
210
  - lib/heroku/forward/proxy/server.rb
211
+ - lib/heroku/forward/utils/dir.rb
211
212
  - lib/heroku/forward/version.rb
212
213
  - LICENSE.md
213
214
  - README.md
@@ -226,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
227
  version: '0'
227
228
  segments:
228
229
  - 0
229
- hash: -4102819039813777077
230
+ hash: 669463106192419404
230
231
  required_rubygems_version: !ruby/object:Gem::Requirement
231
232
  none: false
232
233
  requirements: