キモブロ

Please spy check please, Fucking retard

Capistranoでマルチステージング

developmentとproductionでファイルのデプロイ先を変更したりする方法を探していたのだけど、multistageプラグインという名前の通りの機能によって実現出来た。(通常だと環境変数の値でproductionとdevelopmentの切り替えを行う)


その他細かいメモ

  • rbenvがうまく扱えなかったのだけど、:default_environmentというのを設定したらうまく動くようになった。
  • restart時にrake assets:precompileをするようにした。(これはrestart時ではなくて個別のタスクを作った方が良いかも?)


例:

require 'capistrano/ext/multistage'

set :application, "capistrano sample"
set :repository,  "git@bitbucket.org:kimoto/capistrano-sample.git"
role :web, "localhost"
role :app, "localhost"
role :db,  "localhost", :primary => true
set :user, 'kimoto'
set :group, 'users'
set :use_sudo, false
default_run_options[:pty] = true
set :default_environment, {
    'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}

namespace :deploy do
  task :start do; end
  task :stop do; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "cd #{current_path} && rake assets:precompile"
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end