#### TEST_APPにアプリ名を登録 #### set :application, "TEST_APP"
# capistranoの出力をカラーに require 'capistrano_colors'
# cap deploy時に自動で bundle installを実行 require "bundler/capistrano" set :bundle_flags, "--no-deployment --without test development"
# RVMを利用している場合は必要 require "rvm/capistrano" #### RVMで利用するRubyのバージョンを設定(1.9.3を変更) #### set :rvm_ruby_string, '1.9.3' set :rvm_type, :user # rvmのパスは環境によって変更してください set :rvm_path, '/usr/local/rvm' set :rvm_bin_path, "#{rvm_path}/bin" set :rvm_lib_path, "#{rvm_path}/lib"
# gitリポジトリの設定 #### git_remote_urlにgitのリモートURLを登録 #### set :repository, "git_remote_url" set :scm, :git set :branch, "master" set :deploy_via, :remote_cache #### deploy_folder_path : デプロイ先のフォルダパスを設定 #### set :deploy_to, "deploy_folder_path" set :rails_env, "production"
set :normalize_asset_timestamps, false # 過去のデプロイしたフォルダを履歴として保持する数 set :keep_releases, 5
# assets:precompile namespace :assets do task :precompile, :roles => :web do run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake assets:precompile" end end
namespace :deploy do # Passengerの実行ユーザー/Groupをセット task :set_file_process_owner do sudo "chown -R #{user}.#{user_group} #{deploy_to}" end
# 本番サーバでPassenger以外を使っている場合は適宜変更して下さい。 desc "Passenger用に起動/停止タスクを変更" task :restart, :roles => :web do run "touch #{current_path}/tmp/restart.txt" end end
# deploy ========================== before :deploy, "deploy:set_file_process_owner" after :deploy, "maintenance:on" after :deploy, "deploy:migrate" after :deploy, "assets:precompile" after :deploy, "deploy:restart" after :deploy, "maintenance:off" after :deploy, "deploy:cleanup" # 古い履歴のフォルダを削除
namespace :deploy do desc "sitemapの更新" task :refresh_sitemaps do run "cd #{latest_release} && RAILS_ENV=#{rails_env} bundle exec rake sitemap:refresh" end end after :deploy, "deploy:refresh_sitemaps"
namespace :deploy do desc "Load the seed data from db/seeds.rb" task :seed do run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake db:seed_fu" end end after :deploy, "deploy:seed"
namespace :deploy do # namespaceは任意 desc "Load the seed data from db/data.yml" task :dump_yml_load do run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake db:load" end end after :deploy, "deploy:dump_yml_load"