TeX and CSS tweaks.

Sync with latest Instiki Trunk
(Updates Rails to 1.2.2)
This commit is contained in:
Jacques Distler 2007-02-09 02:04:31 -06:00
parent 0ac586ee25
commit c358389f25
443 changed files with 24218 additions and 9823 deletions

View file

@ -6,11 +6,13 @@ require 'rbconfig'
class RailsFCGIHandler
SIGNALS = {
'HUP' => :reload,
'INT' => :exit_now,
'TERM' => :exit_now,
'USR1' => :exit,
'USR2' => :restart,
'SIGTRAP' => :breakpoint
}
GLOBAL_SIGNALS = SIGNALS.keys - %w(USR1)
attr_reader :when_ready
@ -50,25 +52,7 @@ class RailsFCGIHandler
run_gc! if gc_request_period
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)
break
when :breakpoint
close_connection(cgi)
breakpoint!
end
gc_countdown
end
process_each_request!(provider)
GC.enable
dispatcher_log :info, "terminated gracefully"
@ -76,7 +60,7 @@ class RailsFCGIHandler
rescue SystemExit => exit_error
dispatcher_log :info, "terminated by explicit exit"
rescue Object => fcgi_error
rescue Exception => fcgi_error # FCGI errors
# retry on errors that would otherwise have terminated the FCGI process,
# but only if they occur more than 10 seconds apart.
if !(SignalException === fcgi_error) && Time.now - @last_error_on > 10
@ -87,9 +71,9 @@ class RailsFCGIHandler
dispatcher_error(fcgi_error, "killed by this error")
end
end
private
protected
def logger
@logger ||= Logger.new(@log_file_path)
end
@ -97,7 +81,7 @@ class RailsFCGIHandler
def dispatcher_log(level, msg)
time_str = Time.now.strftime("%d/%b/%Y:%H:%M:%S")
logger.send(level, "[#{time_str} :: #{$$}] #{msg}")
rescue Object => log_error
rescue Exception => log_error # Logger errors
STDERR << "Couldn't write to #{@log_file_path.inspect}: #{msg}\n"
STDERR << " #{log_error.class}: #{log_error.message}\n"
end
@ -110,17 +94,23 @@ class RailsFCGIHandler
end
def install_signal_handlers
SIGNALS.each do |signal, handler_name|
install_signal_handler(signal, method("#{handler_name}_handler").to_proc)
end
GLOBAL_SIGNALS.each { |signal| install_signal_handler(signal) }
end
def install_signal_handler(signal, handler)
def install_signal_handler(signal, handler = nil)
handler ||= method("#{SIGNALS[signal]}_handler").to_proc
trap(signal, handler)
rescue ArgumentError
dispatcher_log :warn, "Ignoring unsupported signal #{signal}."
end
def with_signal_handler(signal)
install_signal_handler(signal)
yield
ensure
install_signal_handler(signal, 'DEFAULT')
end
def exit_now_handler(signal)
dispatcher_log :info, "asked to terminate immediately"
exit
@ -146,9 +136,37 @@ class RailsFCGIHandler
@when_ready = :breakpoint
end
def process_each_request!(provider)
cgi = nil
provider.each_cgi do |cgi|
with_signal_handler 'USR1' do
process_request(cgi)
end
case when_ready
when :reload
reload!
when :restart
close_connection(cgi)
restart!
when :exit
close_connection(cgi)
break
when :breakpoint
close_connection(cgi)
breakpoint!
end
gc_countdown
end
rescue SignalException => signal
raise unless signal.message == 'SIGUSR1'
close_connection(cgi) if cgi
end
def process_request(cgi)
Dispatcher.dispatch(cgi)
rescue Object => e
rescue Exception => e # errors from CGI dispatch
raise if SignalException === e
dispatcher_error(e)
end
@ -157,7 +175,7 @@ class RailsFCGIHandler
config = ::Config::CONFIG
ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
command_line = [ruby, $0, ARGV].flatten.join(' ')
dispatcher_log :info, "restarted"
exec(command_line)
@ -179,7 +197,7 @@ class RailsFCGIHandler
Dispatcher.reset_application!
ActionController::Routing::Routes.reload
end
def breakpoint!
require 'breakpoint'
port = defined?(BREAKPOINT_SERVER_PORT) ? BREAKPOINT_SERVER_PORT : 42531
@ -193,15 +211,15 @@ class RailsFCGIHandler
@gc_request_countdown = gc_request_period
GC.enable; GC.start; GC.disable
end
def gc_countdown
if gc_request_period
@gc_request_countdown -= 1
run_gc! if @gc_request_countdown <= 0
end
end
def close_connection(cgi)
cgi.instance_variable_get("@request").finish
end
end
end