EC2onRails
- config/dep
loy.rb を用意 (サンプルファイルはこちら) :server_co
を適当に設定し、指定したPATHにディレクトリを作る。nfig_files _root - Capfileを以下のような感じで用意。
1 load 'deploy' if respond_to
?(:namespace) # cap2 differenti ator 2 load 'config/dep loy' 3 require 'ec2onrails /recipes' 4 5 set :deploy_to, "/mnt/app/<app_name>" 6 7 # override default start/stop /restart tasks 8 namespace :deploy do 9 desc <<-"DESC" 10 Overrides the default Capistrano deploy:start, directly calls \ 11 /etc/init.d/mongrel #{applicatio n} 12 DESC 13 task :start, :roles => :app do 14 run "/etc/init. d/mongrel start #{applicatio n}" 15 end 16 17 desc <<-"DESC" 18 Overrides the default Capistrano deploy:stop, directly calls \ 19 /etc/init.d/mongrel #{applicatio n} 20 DESC 21 task :stop, :roles => :app do 22 run "/etc/init. d/mongrel stop #{applicatio n}" 23 end 24 25 desc <<-"DESC" 26 Overrides the default Capistrano deploy:restart, directly calls \ 27 /etc/init.d/mongrel #{applicatio n} 28 DESC 29 task :restart, :roles => :app do 30 run "/etc/init. d/mongrel restart #{applicatio n}" 31 end 32 end EC2onRailsが上書きしたデフォルトのタスクをさらに上書きして、複数アプリ対応できるようにしています。 3. 最後に、mongrel_cl usterを使うので、 config/mon
ファイルを用意します。grel_clust er.yml 1 --- 2 cwd: /mnt/app/<app_name>/current 3 port: 8000 4 environmen
t: production 5 pid_file: log/mongre l.pid 6 servers: 3 ポート番号はサーバをシェアするアプリ間で適当に割り振ります。
あとは、以下のコマンドを実行してデプロイします。
1 cap ec2onrails:setup 2 cap deploy:col d
最後に、EC2onRails
posted by
genki
on Wed 21 May 2008
at 18:27