Class: Hayabusa::Fcgi_server
- Inherits:
-
Object
- Object
- Hayabusa::Fcgi_server
- Defined in:
- lib/hayabusa_fcgi_server.rb
Overview
This class is used to start Hayabusa in its own process, which FCGI-sessions then connects to. This way only one instance of Hayabusa is actually running to allowed FCGI-sessions to “commuicate” with each other (because they are running in the same process).
Instance Attribute Summary collapse
-
#hayabusa ⇒ Object
readonly
Returns the value of attribute hayabusa.
Instance Method Summary collapse
-
#initialize(args) ⇒ Fcgi_server
constructor
A new instance of Fcgi_server.
-
#on_http_session_destruct(*args) ⇒ Object
Called when a HTTP-session destructs (disconnects).
Constructor Details
#initialize(args) ⇒ Fcgi_server
Returns a new instance of Fcgi_server.
5 6 7 8 9 10 11 12 |
# File 'lib/hayabusa_fcgi_server.rb', line 5 def initialize(args) #Start web-server for proxy-requests. @hayabusa = Hayabusa.new(args[:hayabusa_conf]) @hayabusa.start #In FCGI-mode the host-process should exit when zero FCGI-connections are active. @hayabusa.events.connect(:http_session_destruct, &self.method(:on_http_session_destruct)) end |
Instance Attribute Details
#hayabusa ⇒ Object (readonly)
Returns the value of attribute hayabusa.
3 4 5 |
# File 'lib/hayabusa_fcgi_server.rb', line 3 def hayabusa @hayabusa end |
Instance Method Details
#on_http_session_destruct(*args) ⇒ Object
Called when a HTTP-session destructs (disconnects). Used to stop the Hayabusa-appserver when no connections are active to only be running when FCGI-sessions are running.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hayabusa_fcgi_server.rb', line 15 def on_http_session_destruct(*args) @hayabusa.log_puts("HTTP-connection destruction - checking if no connections are active any more.") stop = false httpserv = @hayabusa.httpserv if !httpserv or !httpserv.http_sessions or httpserv.http_sessions.empty? stop = true end if stop @hayabusa.log_puts("Stopping server because no active connections.") @hayabusa.stop end end |