Class: Heroku::Forward::Backends::Thin

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/forward/backends/thin.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#application, #environment, #pid, #socket

Instance Method Summary collapse

Methods inherited from Base

#spawned?, #terminate!

Constructor Details

#initialize(options = {}) ⇒ Thin

options:

application:   passed with     -R, eg. app.ru
socket:        passed with     --socket, eg. /tmp/thin.sock
env:           passed with     -e, defaults to 'development'
ssl:           activated with  --ssl
ssl_key_file:  passed with     ssl_key_file PATH
ssl_cert_file: passed with     ssl_cert_file PATH
ssl_verify:    activated with  ssl_verify


20
21
22
23
24
25
26
27
28
29
# File 'lib/heroku/forward/backends/thin.rb', line 20

def initialize(options = {})
  @application = options[:application]
  @socket = options[:socket] || Heroku::Forward::Utils::Dir.tmp_filename('thin-', '.sock')
  @env = options[:env] || :development

  @ssl = options[:ssl] || false
  @ssl_key_file = options[:ssl_key_file] || false
  @ssl_cert_file = options[:ssl_cert_file] || false
  @ssl_verify = options[:ssl_verify] || false
end

Instance Attribute Details

#sslObject

Returns the value of attribute ssl.



7
8
9
# File 'lib/heroku/forward/backends/thin.rb', line 7

def ssl
  @ssl
end

#ssl_cert_fileObject

Returns the value of attribute ssl_cert_file.



9
10
11
# File 'lib/heroku/forward/backends/thin.rb', line 9

def ssl_cert_file
  @ssl_cert_file
end

#ssl_key_fileObject

Returns the value of attribute ssl_key_file.



8
9
10
# File 'lib/heroku/forward/backends/thin.rb', line 8

def ssl_key_file
  @ssl_key_file
end

#ssl_verifyObject

Returns the value of attribute ssl_verify.



10
11
12
# File 'lib/heroku/forward/backends/thin.rb', line 10

def ssl_verify
  @ssl_verify
end

Instance Method Details

#spawn!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/heroku/forward/backends/thin.rb', line 31

def spawn!
  return false if spawned?
  check!

  spawn_with = [ "thin" ]
  spawn_with.push "start"
  spawn_with.push "-R", @application
  spawn_with.push "--socket", @socket
  spawn_with.push "-e", @env.to_s
  spawn_with.push "--ssl" if @ssl
  spawn_with.push "--ssl-key-file", @ssl_key_file if @ssl_key_file
  spawn_with.push "--ssl-cert-file", @ssl_cert_file if @ssl_cert_file
  spawn_with.push "--ssl-verify" if @ssl_verify

  @pid = Spoon.spawnp(* spawn_with)
  @spawned = true
end