PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/forbestechnosys/kms
Ruby | 102 lines | 59 code | 16 blank | 27 comment | 10 complexity | 3b8c968faa02f57fcea2cd89dc62f9f3 MD5 | raw file
  1. # This is a sample Capistrano config file for rubber
  2. set :rails_env, Rubber.env
  3. on :load do
  4. set :application, rubber_env.app_name
  5. set :runner, rubber_env.app_user
  6. set :deploy_to, "/mnt/#{application}-#{Rubber.env}"
  7. set :copy_exclude, [".git/*", ".bundle/*", "log/*", ".rvmrc", ".rbenv-version"]
  8. end
  9. # Use a simple directory tree copy here to make demo easier.
  10. # You probably want to use your own repository for a real app
  11. # set :scm, :none
  12. # set :repository, "."
  13. set :deploy_via, :remote_cache
  14. set :scm, :git
  15. set :repository, "https://rahul_jayaraman@bitbucket.org/forbestechnosys/kms.git"
  16. set :branch, "master"
  17. # Easier to do system level config as root - probably should do it through
  18. # sudo in the future. We use ssh keys for access, so no passwd needed
  19. set :user, 'root'
  20. set :password, nil
  21. # Use sudo with user rails for cap deploy:[stop|start|restart]
  22. # This way exposed services (mongrel) aren't running as a privileged user
  23. set :use_sudo, true
  24. # How many old releases should be kept around when running "cleanup" task
  25. set :keep_releases, 3
  26. # Lets us work with staging instances without having to checkin config files
  27. # (instance*.yml + rubber*.yml) for a deploy. This gives us the
  28. # convenience of not having to checkin files for staging, as well as
  29. # the safety of forcing it to be checked in for production.
  30. set :push_instance_config, Rubber.env != 'production'
  31. # don't waste time bundling gems that don't need to be there
  32. set :bundle_without, [:development, :test, :staging] if Rubber.env == 'production'
  33. # Allow us to do N hosts at a time for all tasks - useful when trying
  34. # to figure out which host in a large set is down:
  35. # RUBBER_ENV=production MAX_HOSTS=1 cap invoke COMMAND=hostname
  36. max_hosts = ENV['MAX_HOSTS'].to_i
  37. default_run_options[:max_hosts] = max_hosts if max_hosts > 0
  38. # Allows the tasks defined to fail gracefully if there are no hosts for them.
  39. # Comment out or use "required_task" for default cap behavior of a hard failure
  40. rubber.allow_optional_tasks(self)
  41. # Wrap tasks in the deploy namespace that have roles so that we can use FILTER
  42. # with something like a deploy:cold which tries to run deploy:migrate but can't
  43. # because we filtered out the :db role
  44. namespace :deploy do
  45. rubber.allow_optional_tasks(self)
  46. tasks.values.each do |t|
  47. if t.options[:roles]
  48. task t.name, t.options, &t.body
  49. end
  50. end
  51. end
  52. namespace :deploy do
  53. namespace :assets do
  54. rubber.allow_optional_tasks(self)
  55. tasks.values.each do |t|
  56. if t.options[:roles]
  57. task t.name, t.options, &t.body
  58. end
  59. end
  60. end
  61. end
  62. # load in the deploy scripts installed by vulcanize for each rubber module
  63. Dir["#{File.dirname(__FILE__)}/rubber/deploy-*.rb"].each do |deploy_file|
  64. load deploy_file
  65. end
  66. # capistrano's deploy:cleanup doesn't play well with FILTER
  67. after "deploy", "cleanup"
  68. after "deploy:migrations", "cleanup"
  69. task :cleanup, :except => { :no_release => true } do
  70. count = fetch(:keep_releases, 5).to_i
  71. rsudo <<-CMD
  72. all=$(ls -x1 #{releases_path} | sort -n);
  73. keep=$(ls -x1 #{releases_path} | sort -n | tail -n #{count});
  74. remove=$(comm -23 <(echo -e "$all") <(echo -e "$keep"));
  75. for r in $remove; do rm -rf #{releases_path}/$r; done;
  76. CMD
  77. end
  78. if Rubber::Util.has_asset_pipeline?
  79. # load asset pipeline tasks, and reorder them to run after
  80. # rubber:config so that database.yml/etc has been generated
  81. load 'deploy/assets'
  82. callbacks[:after].delete_if {|c| c.source == "deploy:assets:precompile"}
  83. callbacks[:before].delete_if {|c| c.source == "deploy:assets:symlink"}
  84. before "deploy:assets:precompile", "deploy:assets:symlink"
  85. after "rubber:config", "deploy:assets:precompile"
  86. end