Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set :repository, "git@bitbucket.org:repo/repo.git"
- set :user, "deploy"
- set :use_sudo, false
- set :scm, :git
- set :keep_releases, 5
- set :domain, "000.000.000.000"
- set :application, "my_app"
- set :rails_env, "production"
- set :branch, "master"
- set :deploy_to, "/var/www/#{application}"
- set :port, 22
- server domain, :app, :web, :db, :primary => true
- namespace :deploy do
- task :start do ; end
- task :stop do ; end
- task :restart, :roles => :app, :except => { :no_release => true } do
- run "touch #{shared_path}/#{application}-restart.txt"
- end
- desc "Reload the database with seed data"
- task :seed do
- run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
- end
- namespace :web do
- desc "Present a maintenance page to visitors"
- task :disable, :roles => :web, :except => { :no_release => true } do
- on_rollback { run "rm #{shared_path}/system/maintenance.html" }
- template = File.read("./public/503.html")
- put template, "#{shared_path}/system/maintenance.html", :mode => 0644
- end
- end
- namespace :assets do
- desc 'Install asset dependencies'
- task :install, roles: :app do
- run "cd #{latest_release} && bower install --no-color"
- end
- end
- end
- namespace :log do
- namespace :tail do
- desc "Show the production log"
- task :app, roles: :app do
- run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
- puts "#{data}"
- break if stream == :err
- end
- end
- end
- end
- namespace :db do
- desc "Create database yaml in shared path"
- task :configure do
- set :database do
- Capistrano::CLI.password_prompt "Database: "
- end
- set :database_username do
- Capistrano::CLI.password_prompt "Database Username: "
- end
- set :database_password do
- Capistrano::CLI.password_prompt "Database Password: "
- end
- set :database_host do
- Capistrano::CLI.password_prompt "Database Host: "
- end
- db_config = <<-EOF
- production:
- database: #{database}
- adapter: mysql2
- encoding: utf8
- reconnect: false
- pool: 5
- username: #{database_username}
- password: #{database_password}
- host: #{database_host}
- EOF
- run "mkdir -p #{shared_path}/config"
- put db_config, "#{shared_path}/config/database.yml"
- end
- desc "Make symlink for database yaml"
- task :symlink do
- run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
- end
- end
- before 'deploy:assets:precompile', 'db:symlink'
- before 'deploy:assets:precompile', 'deploy:assets:install'
- before 'deploy:setup', 'db:configure'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement