Class: Heroku::Forward::Backends::Unicorn

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/forward/backends/unicorn.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 = {}) ⇒ Unicorn

Returns a new instance of Unicorn.



9
10
11
12
13
14
# File 'lib/heroku/forward/backends/unicorn.rb', line 9

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

Instance Attribute Details

#config_fileObject

Returns the value of attribute config_file.



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

def config_file
  @config_file
end

Instance Method Details

#spawn!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/heroku/forward/backends/unicorn.rb', line 16

def spawn!
  return false if spawned?
  check!

  args = ['unicorn']
  args.push '--env', @env
  args.push '--config-file', @config_file if @config_file
  args.push '--listen', @socket
  args.push @application

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