Class: Heroku::Forward::Backends::Puma

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

Instance Attribute Summary collapse

Attributes inherited from Base

#application, #environment, #pid, #socket

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Puma

Returns a new instance of Puma.



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

def initialize(options = {})
  @application = options[:application]
  @socket = options[:socket] || Heroku::Forward::Utils::Dir.tmp_filename('puma-', '.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/puma.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/puma.rb', line 16

def spawn!
  return false if spawned?
  check!

  args = ['puma']
  args.push '--environment', @env
  args.push '--config', @config_file if @config_file
  args.push '--bind', "unix://#{@socket}"
  args.push @application

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

#spawned?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/heroku/forward/backends/puma.rb', line 37

def spawned?
  !!@spawned
end

#terminate!Object



30
31
32
33
34
35
# File 'lib/heroku/forward/backends/puma.rb', line 30

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