Rails source code analysis (1): RailsFCGIHandler
Advertisements
Ruby CGI Doc:
The Common Gateway Interface ( ) Is a simple protocol for passing an HTTP request from a web server to a standalone program, and returning the output to the web browser. Basically, a program is called with the parameters of the request passed in either in the environment (GET) or via $ stdin (POST), and everything it prints to $ stdout is returned to the client.
This class focuses on process! Methods:
- def process! (provider = FCGI)
- mark_features!
- dispatcher_log: info, 'starting'
- process_each_request provider
- dispatcher_log: info, 'stopping gracefully'
- rescue Exception => error
- case error
- when SystemExit
- dispatcher_log: info, 'stopping after explicit exit'
- when SignalException
- dispatcher_error error, 'stopping after unhandled signal'
- else
- # Retry if exceptions occur more than 10 seconds apart.
- if Time.now - @ last_error_on> 10
- @ last_error_on = Time.now
- dispatcher_error error, 'retrying after unhandled exception'
- retry
- else
- dispatcher_error error, 'stopping after unhandled exception within 10 seconds of the last'
- end
- end
- end
(1) mark_features!
def mark_features!
@ features = $ ". clone
end
/ / Through the $ "to be all Rails loaded. Rb file name composed of list
(2) process_each_request
- def process_each_request (provider)
- cgi = nil
- catch: exit do
- provider.each_cgi do | cgi |
- process_request (cgi)
- case when_ready
- when: reload
- reload!
- when: restart
- close_connection (cgi)
- restart!
- when: exit
- close_connection (cgi)
- throw: exit
- end
- end
- end
- rescue SignalException => signal
- raise unless signal.message == 'SIGUSR1'
- close_connection (cgi)
- end
(3) process_request
- def process_request (cgi)
- @ processing, @ when_ready = true, nil
- gc_countdown
- with_signal_handler 'USR1' do
- begin
- Dispatcher.dispatch (cgi)
- rescue SignalException, SystemExit
- raise
- rescue Exception => error
- dispatcher_error error, 'unhandled dispatch error'
- end
- end
- ensure
- @ processing = false
- end
Next on the inside of the Dispatcher
Related Posts of Rails source code analysis (1): RailsFCGIHandler
-
Using Rails Captcha plug-in, easy implementation Verification Code
Simple Captcha Plugin Can help us easily in the Rails implementation of Verification Code function. In addition, he has the option to provide sufficient to meet the U.S. requirements for certification, the use of easy. Supported picture and digital authen
-
RSpec troubleshooting
1.uninitialized constant Dependencies Conditions: In windows under way to install the RSpec gem and rspec-rails. However, in ruby script / spec_server to do the test under the spec your_spec.rb-X will appear uninitialized constant Dependencies (NameE ...
-
Alternative to Java with Ruby to do unit testing interface rest!
Ruby is long overdue to replace java more flexible and make some necessary changes in a matter of, if not deep-rooted culture of the company's java, I think. . . . . . The following are my Writing for the Rest of the interface used to make the test su
-
Answer: After 2.2 upgrade mysql question-driven
windows installed after the mysql gem error, error is approximately: ArgumentError (NULL pointer given): (eval): 3: in `each_hash ' (eval): 3: in `all_hashes' This is feeling under the windows of the question if the mysql gem version libmysql ...
-
Workspace run under different Eclipse
Now do live more and more often required to use eclipse in java and ruby & rails project conducted between the tangential shear from the past, because in the rails project used a coloring Aptana preferences, the results open the java project sour ...
-
Hibernate Inteceptor
The end of the project stage, the client suddenly put forward a very troublesome but normal demand, the system records all changes must be carried out. Formats such as: 2004.1.1 12:30 Ikuya wind orders Sales Order Date 2004.1.2-> 2004.1.3 The firs ...
-
FLEX: integrating Spring + Hibernate
Before a friend also wanted to study development of FLEX. Asked me to help him to be a small sample. Spent a weekend time, to integrate a sampleproject. Client: FLEX Server: Spring2.5 + Hibernate3.2 + Hibernate-annotations3.3.1 + MySQL5 FDS: BlazeDS3 IDE:
-
Oracle instant clent for ruby / rails on cygwin
Environment: XP: oracle full client, ruby, rails, gem cygwin: ruby rails, gem (the version with the XP version) Needs: for cygwin is installed under the rails platform support oci Steps: <1> download oracle instant client (10.2.0.3 Instant Client Pa
-
Ruby on Rails Routing - Simple Examples
This article contains a list of ruby on rails routing examples. If you find you have any questions please leave a comment. Routes are processed from the top of routes.rb down. If a route is matched it will stop processing the routes.rb file and use that r
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q












