Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. set :repository, "git@bitbucket.org:repo/repo.git"
  2. set :user, "deploy"
  3. set :use_sudo, false
  4. set :scm, :git
  5. set :keep_releases, 5
  6. set :domain, "000.000.000.000"
  7. set :application, "my_app"
  8. set :rails_env, "production"
  9. set :branch, "master"
  10. set :deploy_to, "/var/www/#{application}"
  11. set :port, 22
  12. server domain, :app, :web, :db, :primary => true
  13.  
  14. namespace :deploy do
  15. task :start do ; end
  16. task :stop do ; end
  17. task :restart, :roles => :app, :except => { :no_release => true } do
  18. run "touch #{shared_path}/#{application}-restart.txt"
  19. end
  20.  
  21. desc "Reload the database with seed data"
  22. task :seed do
  23. run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
  24. end
  25.  
  26. namespace :web do
  27. desc "Present a maintenance page to visitors"
  28. task :disable, :roles => :web, :except => { :no_release => true } do
  29. on_rollback { run "rm #{shared_path}/system/maintenance.html" }
  30.  
  31. template = File.read("./public/503.html")
  32.  
  33. put template, "#{shared_path}/system/maintenance.html", :mode => 0644
  34. end
  35. end
  36.  
  37. namespace :assets do
  38. desc 'Install asset dependencies'
  39. task :install, roles: :app do
  40. run "cd #{latest_release} && bower install --no-color"
  41. end
  42. end
  43. end
  44.  
  45. namespace :log do
  46. namespace :tail do
  47. desc "Show the production log"
  48. task :app, roles: :app do
  49. run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
  50. puts "#{data}"
  51. break if stream == :err
  52. end
  53. end
  54. end
  55. end
  56.  
  57. namespace :db do
  58. desc "Create database yaml in shared path"
  59. task :configure do
  60. set :database do
  61. Capistrano::CLI.password_prompt "Database: "
  62. end
  63.  
  64. set :database_username do
  65. Capistrano::CLI.password_prompt "Database Username: "
  66. end
  67.  
  68. set :database_password do
  69. Capistrano::CLI.password_prompt "Database Password: "
  70. end
  71.  
  72. set :database_host do
  73. Capistrano::CLI.password_prompt "Database Host: "
  74. end
  75.  
  76. db_config = <<-EOF
  77. production:
  78. database: #{database}
  79. adapter: mysql2
  80. encoding: utf8
  81. reconnect: false
  82. pool: 5
  83. username: #{database_username}
  84. password: #{database_password}
  85. host: #{database_host}
  86. EOF
  87.  
  88. run "mkdir -p #{shared_path}/config"
  89. put db_config, "#{shared_path}/config/database.yml"
  90. end
  91.  
  92. desc "Make symlink for database yaml"
  93. task :symlink do
  94. run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
  95. end
  96. end
  97.  
  98. before 'deploy:assets:precompile', 'db:symlink'
  99. before 'deploy:assets:precompile', 'deploy:assets:install'
  100. before 'deploy:setup', 'db:configure'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement