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







