Class: Uc::Unicorn::Prestart
- Inherits:
-
Object
- Object
- Uc::Unicorn::Prestart
- Includes:
- Logger
- Defined in:
- lib/uc/unicorn/prestart.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
- #app ⇒ Object
- #id ⇒ Object
-
#initialize(server, worker, url: "/") ⇒ Prestart
constructor
A new instance of Prestart.
- #make_prestart_request ⇒ Object
- #run ⇒ Object
Methods included from Logger
#event_queue, event_stream, #event_stream, logger, #logger, stderr, #stderr
Constructor Details
#initialize(server, worker, url: "/") ⇒ Prestart
Returns a new instance of Prestart.
10 11 12 13 14 |
# File 'lib/uc/unicorn/prestart.rb', line 10 def initialize(server, worker, url: "/") @server = server @worker = worker @url = url end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
7 8 9 |
# File 'lib/uc/unicorn/prestart.rb', line 7 def server @server end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/uc/unicorn/prestart.rb', line 7 def url @url end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
7 8 9 |
# File 'lib/uc/unicorn/prestart.rb', line 7 def worker @worker end |
Instance Method Details
#app ⇒ Object
16 17 18 |
# File 'lib/uc/unicorn/prestart.rb', line 16 def app @app ||= server.instance_variable_get("@app") end |
#id ⇒ Object
37 38 39 |
# File 'lib/uc/unicorn/prestart.rb', line 37 def id @id ||= worker.nr + 1 end |
#make_prestart_request ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/uc/unicorn/prestart.rb', line 24 def make_prestart_request event_stream.debug "prestarting worker #{id}" response = app.call(rack_request) body = response[2] if body.is_a? Rack::BodyProxy body.close end event_stream.debug "worker #{id} prestart successful" rescue => e event_stream.warn "prestart failed for worker #{id}, #{e.class}" end |
#run ⇒ Object
20 21 22 |
# File 'lib/uc/unicorn/prestart.rb', line 20 def run make_prestart_request end |