Class: RailsSCGIProcessor
- Inherits:
-
SCGI::Processor
- Object
- Monitor
- SCGI::Processor
- RailsSCGIProcessor
- Defined in:
- lib/RailsSCGIProcessor.rb
Overview
This SCGI::Processor subclass hooks the SCGI request into Ruby on Rails.
Instance Attribute Summary
Attributes inherited from SCGI::Processor
Instance Method Summary collapse
-
#initialize(settings) ⇒ RailsSCGIProcessor
constructor
Initialzes Rails with the appropriate environment and settings.
-
#process_request(request, body, socket) ⇒ Object
Submits requests to Rails in a single threaded fashion.
Methods inherited from SCGI::Processor
#collect_thread, #handle_client, #listen, #read_header, #setup_signals, #shutdown, #status_info
Constructor Details
#initialize(settings) ⇒ RailsSCGIProcessor
Initialzes Rails with the appropriate environment and settings
7 8 9 10 11 12 13 14 |
# File 'lib/RailsSCGIProcessor.rb', line 7 def initialize(settings) ENV["RAILS_ENV"] = settings[:environment] || 'production' require "config/environment" ActiveRecord::Base.threaded_connections = false require 'dispatcher' super(settings) @guard = Mutex.new end |
Instance Method Details
#process_request(request, body, socket) ⇒ Object
Submits requests to Rails in a single threaded fashion
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/RailsSCGIProcessor.rb', line 17 def process_request(request, body, socket) return if socket.closed? cgi = SCGI::CGIFixed.new(request, body, socket) begin @guard.synchronize{Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, cgi.stdoutput)} rescue IOError @log.error("received IOError #$! when handling client. Your web server doesn't like me.") rescue Object => rails_error @log.error("calling Dispatcher.dispatch", rails_error) end end |