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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Unicorn

Returns a new instance of Unicorn.



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

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

#applicationObject

Returns the value of attribute application.



5
6
7
# File 'lib/heroku/forward/backends/unicorn.rb', line 5

def application
  @application
end

#config_fileObject

Returns the value of attribute config_file.



5
6
7
# File 'lib/heroku/forward/backends/unicorn.rb', line 5

def config_file
  @config_file
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/heroku/forward/backends/unicorn.rb', line 5

def environment
  @environment
end

#pidObject

Returns the value of attribute pid.



5
6
7
# File 'lib/heroku/forward/backends/unicorn.rb', line 5

def pid
  @pid
end

#socketObject

Returns the value of attribute socket.



5
6
7
# File 'lib/heroku/forward/backends/unicorn.rb', line 5

def socket
  @socket
end

Instance Method Details

#spawn!Object



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

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

#spawned?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/heroku/forward/backends/unicorn.rb', line 35

def spawned?
  !!@spawned
end

#terminate!Object



28
29
30
31
32
33
# File 'lib/heroku/forward/backends/unicorn.rb', line 28

def terminate!
  return false unless spawned?
  Process.kill 'QUIT', @pid
  @spawned = false
  true
end