加藤です。
lighty + FastCGIよりも、Apache + Mongrel の方がセットアップがラクだなぁと思う今日この頃、"Capistrano":http://manuals.rubyonrails.com/read/book/17 の設定を忘れてしまいそうなのでメモ。
config/deploy.rbではMongrel Cluster用のレシピを読み込んで、オプション変数にmongrel_cluster.ymlの場所をセットします。
require 'mongrel_cluster/recipes'
# This defines a deployment "recipe" that you can feed to capistrano
...
# =============================================================================
# OPTIONAL VARIABLES
# =============================================================================
set :deploy_to, "/home/www/myapp"
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
...
次に、環境にもよりますが、リモート側でmongrelのpidファイルを見つけられないことがあるので、mongrel_cluster.ymlではカレントディレクトリの場所を指定しておきましょう。
---
port: "3001"
environment: production
pid_file: log/mongrel.pid
servers: 5
cwd: /home/www/myapp/current
以上で、deploy時にMongrel Clusterを再起動してくれます。
% cap deploy
...
* executing task restart
* executing task restart_mongrel_cluster
* executing "sudo mongrel_rails cluster::restart -C /home/www/myapp/current/config/mongrel_cluster.yml"
servers: ["foo.example.com"]
[foo.example.com] executing command
** [out :: foo.example.com] Stopping 5 Mongrel servers...
** [out :: foo.example.com] Starting 5 Mongrel servers...
command finished
あと、以前からさんざん警告が出ていたので、言われた通りgemでtermiosを入れたらdeploy中パスワードがシェルウィンドウに表示されなくなりました。隣の人の視線が気になるかたはこちらもぜひ。
% sudo gem install termios
Capistranoの新しいサイト を見てみると2.0ではだいぶやり方が変わりそうです。ちなみに僕の今のバージョンはこんな感じ。
% gem list | grep capi
capistrano (1.4.1)