PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/channainfo/papua-new-guinea-hiv-aids
Ruby | 91 lines | 55 code | 24 blank | 12 comment | 0 complexity | b9b77219e014b8d78fa820dfbfdf6faf MD5 | raw file
  1. # sudo groupadd deployers
  2. # sudo usermod -a -G deployers ilab
  3. # sudo chown -R ilab:deployers /var/www
  4. # sudo chmod -R g+w /var/www
  5. # sudo chmod go-w -R /var/www warning Insecure world writable dir /home/chance in PATH, mode 040777 http://stackoverflow.com/questions/5380671/getting-the-warning-insecure-world-writable-dir-home-chance-in-path-mode-04
  6. # ssh config for remote server and repo
  7. require 'whenever'
  8. require "capistrano-rbenv"
  9. set :rbenv_ruby_version, "1.9.3-p392" #2.0.0-p247
  10. set :stages, %w(production staging)
  11. set :default_stage, :production
  12. require 'capistrano/ext/multistage'
  13. require 'bundler/capistrano'
  14. #set :whenever_command, "bundle exec whenever" # for bundler
  15. #set :whenever_environment, defer { stage } # multistaging
  16. #require "whenever/capistrano"
  17. set :application, "png"
  18. set :use_sudo , false
  19. set :repository, "https://channainfo@bitbucket.org/channainfo/papua-new-guinea-hiv-aids.git"
  20. set :scm, :git
  21. set :scm_username, 'channainfo'
  22. set :branch, 'develop'
  23. set :deploy_to, '/var/www/png'
  24. # set :deploy_via, :remote_cache
  25. default_environment['TERM'] = ENV['TERM']
  26. namespace :deploy do
  27. task :start do ; end
  28. task :stop do ; end
  29. task :restart, :roles => :app, :except => { :no_release => true } do
  30. run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  31. end
  32. task :symlink_data, :roles => :app do
  33. run "ln -s #{shared_path}/data #{release_path}/public/data"
  34. run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
  35. end
  36. task :whenever do
  37. run "cd #{release_path} && RAILS_ENV=production bundle exec whenever --update-crontab png-health-system "
  38. end
  39. task :symlink_config, roles: :app do
  40. run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  41. # run "ln -nfs #{shared_path}/config/nuntium.yml #{release_path}/config/nuntium.yml"
  42. run "ln -nfs #{shared_path}/config/application.yml #{release_path}/config/application.yml"
  43. end
  44. end
  45. namespace :db do
  46. task :create do
  47. run "cd #{release_path} && bundle exec rake db:create RAILS_ENV=production"
  48. end
  49. task :seed do
  50. run "cd #{release_path} && bundle exec rake db:seed RAILS_ENV=production"
  51. end
  52. task :default_data do
  53. run "cd #{release_path} && bundle exec rake png:load_default_data RAILS_ENV=production"
  54. end
  55. end
  56. namespace :assets do
  57. task :precompile do
  58. run "cd #{release_path} && bundle exec rake assets:precompile RAILS_ENV=production"
  59. end
  60. end
  61. # deploy:finalize_update
  62. after "deploy:update_code", "deploy:symlink_config"
  63. after "deploy:update_code", "deploy:symlink_data"
  64. after 'deploy:update_code', 'deploy:whenever' # require "whenever/capistrano" does not work because it does not choose the correct database.yml
  65. after 'deploy:update_code', 'assets:precompile' # using builtin capistrano asset:precompile in project root Capfile load 'deploy/assets'
  66. before "deploy:start", "deploy:migrate"
  67. before "deploy:restart", "deploy:migrate"