Class: Heroku::Forward::Backends::Unicorn
- Inherits:
-
Object
- Object
- Heroku::Forward::Backends::Unicorn
- Defined in:
- lib/heroku/forward/backends/unicorn.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Unicorn
constructor
A new instance of Unicorn.
- #spawn! ⇒ Object
- #spawned? ⇒ Boolean
- #terminate! ⇒ Object
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( = {}) @application = [:application] @socket = [:socket] || Heroku::Forward::Utils::Dir.tmp_filename('unicorn-', '.sock') @env = [:env] || 'development' @config_file = [:config_file] end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
5 6 7 |
# File 'lib/heroku/forward/backends/unicorn.rb', line 5 def application @application end |
#config_file ⇒ Object
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 |
#environment ⇒ Object
Returns the value of attribute environment.
5 6 7 |
# File 'lib/heroku/forward/backends/unicorn.rb', line 5 def environment @environment end |
#pid ⇒ Object
Returns the value of attribute pid.
5 6 7 |
# File 'lib/heroku/forward/backends/unicorn.rb', line 5 def pid @pid end |
#socket ⇒ Object
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
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 |