PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/appfellas/appfellasweb
Ruby | 109 lines | 59 code | 30 blank | 20 comment | 1 complexity | b01f2b498aeb87884b622558c48ed35f MD5 | raw file
  1. load "deploy/assets"
  2. set :default_stage, "staging"
  3. set :stages, %w(production staging)
  4. require 'capistrano/ext/multistage'
  5. require 'rvm/capistrano'
  6. set :rvm_ruby_string, 'ruby-1.9.3-p194@global'
  7. set :rvm_type, :system
  8. set :rvm_install_type, :stable
  9. require "bundler/capistrano"
  10. #before 'deploy:setup', 'rvm:install_rvm'
  11. #set :bundle_without, [:development, :test]
  12. #set :bundle_gemfile, "Gemfile"
  13. #set :bundle_flags, "--deployment --quiet"
  14. #set :bundle_dir, fetch(:shared_path)+"/bundle"
  15. set :application, "AppFellas"
  16. set :repository, "git@bitbucket.org:appfellas/appfellasweb.git "
  17. set :user, "appfellas"
  18. set :use_sudo, false
  19. set :keep_releases, 3
  20. set :scm, :git
  21. set :deploy_via, :export
  22. set :git_enable_submodules, 1
  23. #set :stack, :passenger_nginx
  24. #ssh_options[:forward_agent] = true
  25. default_run_options[:pty] = true
  26. #default_run_options[:shell] = '/bin/bash'
  27. # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
  28. # role :web, "appfellas.co" # Your HTTP server, Apache/etc
  29. # role :app, "appfellas.co" # This may be the same as your `Web` server
  30. #role :db, "mongo", :primary => true # This is where Rails migrations will run
  31. #role :db, "your slave db-server here"
  32. # if you're still using the script/reaper helper you will need
  33. # these http://github.com/rails/irs_process_scripts
  34. #before 'deploy:setup', 'rvm:install_ruby'
  35. # If you are using Passenger mod_rails uncomment this:
  36. namespace :deploy do
  37. task :start do ; end
  38. task :stop do ; end
  39. task :restart, :roles => :app, :except => { :no_release => true } do
  40. run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  41. end
  42. end
  43. namespace :rvm do
  44. task :trust_rvmrc do
  45. run "rvm rvmrc trust #{release_path}"
  46. end
  47. end
  48. #after "deploy", "rvm:trust_rvmrc"
  49. namespace :assets do
  50. desc "Create symlink for shared static resources, fx user avatars, etc."
  51. task :symlink, :roles => :app do
  52. assets.create_dirs
  53. run <<-CMD
  54. ln -nfs #{shared_path}/static #{release_path}/public/static
  55. CMD
  56. end
  57. desc "Create dirs"
  58. task :create_dirs, :roles => :app do
  59. %w(static).each do |name|
  60. run "mkdir -p #{shared_path}/#{name}"
  61. end
  62. #subdirs
  63. %w(uploads).each do |name|
  64. run "mkdir -p #{shared_path}/static/#{name}"
  65. end
  66. end
  67. end
  68. ## Run manual
  69. namespace :crontab do
  70. desc "Update crontab"
  71. task :update do
  72. run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec whenever --set 'enviroment=#{rails_env}&cron_log=#{current_path}/log/cron.log' --update-crontab #{application}_#{rails_env}"
  73. end
  74. desc "Clear crontab"
  75. task :clear do
  76. run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec whenever --set 'enviroment=#{rails_env}' --clear-crontab #{application}_#{rails_env}"
  77. end
  78. end
  79. after "deploy:update_code", "assets:symlink"