Head First RailsというRuby on Rails入門書を読んでいて気づいたのでメモ。
Rails 2.3.2で動かすと、dispatch.cgiは自動的に生成されませんでした。
$ ls $HOME/Rails/test/public/
404.html dispatch.cgi favicon.ico javascripts
stylesheets422.html dispatch.fcgi images
public500.html dispatch.rb index.html robots.txt
Rails2.2.2で作成したTodoアプリのdispatch.cgiとdispatch.fcgiはこんな感じ。
dispatch.cgi
$ less $HOME/Rails/Todo/public/dispatch.cgi
#!/usr/local/bin/ruby18
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch
dispatch.fcgi
$ less $HOME/Rails/Todo//public/dispatch.fcgi
#!/usr/local/bin/ruby18
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
#
# Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
#
# Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
#
# Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
RailsFCGIHandler.process!