PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/shinyay/chef_rails_template
Ruby | 52 lines | 36 code | 8 blank | 8 comment | 1 complexity | 4c099c49dcd9e983dee4a774029c2204 MD5 | raw file
  1. set :application, "chef_rails_template"
  2. require 'capistrano_colors'
  3. require "bundler/capistrano"
  4. # リポジトリ
  5. set :scm, :git
  6. #set :repository, "https://shinyay@bitbucket.org/shinyay/chef_rails_template.git"
  7. set :repository, "."
  8. set :branch, "master"
  9. #set :deploy_via, :remote_cache
  10. set :deploy_via, :copy
  11. set :deploy_to, "/var/www/#{application}"
  12. set :rails_env, "production"
  13. # SSH
  14. set :user, "shinyay"
  15. set :use_sudo, false
  16. ssh_options[:forward_agent] = true
  17. default_run_options[:pty] = true
  18. # デプロイ先
  19. role :web, "sakura"
  20. role :app, "sakura"
  21. role :db, "sakura", :primary => true
  22. # precompile
  23. load 'deploy/assets'
  24. # cap deploy:setup 後に実行
  25. namespace :setup do
  26. task :fix_permissions do
  27. sudo "chown -R #{user}.#{user} #{deploy_to}"
  28. end
  29. end
  30. after "deploy:setup", "setup:fix_permissions"
  31. # Unicorn用に起動/停止タスクを変更
  32. namespace :deploy do
  33. task :start, :roles => :app do
  34. run "cd #{current_path}; bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D"
  35. end
  36. task :restart, :roles => :app do
  37. if File.exist? "/tmp/unicorn_#{application}.pid"
  38. run "kill -s USR2 `cat /tmp/unicorn_#{application}.pid`"
  39. end
  40. end
  41. task :stop, :roles => :app do
  42. run "kill -s QUIT `cat /tmp/unicorn_#{application}.pid`"
  43. end
  44. end