Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
Last active November 22, 2017 09:48

Revisions

  1. jtadeulopes revised this gist Mar 17, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -95,6 +95,6 @@
    end
    end

    before 'deploy:assets:precompile', 'db:symlink'
    before 'deploy:assets:precompile', 'deploy:assets:install'
    before 'deploy:setup', 'db:configure'
    after 'deploy:update_code', 'db:symlink'
    before 'deploy:setup', 'db:configure'
  2. jtadeulopes revised this gist Mar 13, 2014. 1 changed file with 48 additions and 5 deletions.
    53 changes: 48 additions & 5 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -35,23 +35,66 @@
    end

    namespace :assets do
    desc 'install asset dependencies'
    desc 'Install asset dependencies'
    task :install, roles: :app do
    run "cd #{latest_release} && bower install --no-color"
    end
    end
    end

    before 'deploy:assets:precompile', 'deploy:assets:install'

    namespace :log do
    namespace :tail do
    desc "Tail no log da aplicação em produção"
    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
    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', 'deploy:assets:install'
    before 'deploy:setup', 'db:configure'
    after 'deploy:update_code', 'db:symlink'
  3. jtadeulopes revised this gist Mar 13, 2014. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion deploy.rb
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@
    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
    @@ -33,8 +33,17 @@
    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

    before 'deploy:assets:precompile', 'deploy:assets:install'

    namespace :log do
    namespace :tail do
    desc "Tail no log da aplicação em produção"
  4. jtadeulopes revised this gist Feb 21, 2014. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,17 @@
    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
    end

    namespace :log do
  5. jtadeulopes revised this gist Nov 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.rb
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    task :start do ; end
    task :stop do ; end
    task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','project-restart.txt')}"
    run "touch #{shared_path}/#{application}-restart.txt"
    end

    desc "Reload the database with seed data"
  6. jtadeulopes revised this gist Nov 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.rb
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    task :start do ; end
    task :stop do ; end
    task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
    run "#{try_sudo} touch #{File.join(current_path,'tmp','project-restart.txt')}"
    end

    desc "Reload the database with seed data"
  7. jtadeulopes revised this gist Nov 1, 2013. 1 changed file with 0 additions and 20 deletions.
    20 changes: 0 additions & 20 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -34,24 +34,4 @@
    end
    end
    end
    end

    namespace :puma do
    desc "Start Puma"
    task :start, :except => { :no_release => true } do
    run "sudo start #{application}"
    end
    after "deploy:start", "puma:start"

    desc "Stop Puma"
    task :stop, :except => { :no_release => true } do
    run "sudo stop #{application}"
    end
    after "deploy:stop", "puma:stop"

    desc "Restart Puma"
    task :restart, roles: :app do
    run "sudo restart #{application}"
    end
    after "deploy:restart", "puma:restart"
    end
  8. jtadeulopes revised this gist Nov 1, 2013. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -34,4 +34,24 @@
    end
    end
    end
    end

    namespace :puma do
    desc "Start Puma"
    task :start, :except => { :no_release => true } do
    run "sudo start #{application}"
    end
    after "deploy:start", "puma:start"

    desc "Stop Puma"
    task :stop, :except => { :no_release => true } do
    run "sudo stop #{application}"
    end
    after "deploy:stop", "puma:stop"

    desc "Restart Puma"
    task :restart, roles: :app do
    run "sudo restart #{application}"
    end
    after "deploy:restart", "puma:restart"
    end
  9. jtadeulopes created this gist Oct 31, 2013.
    37 changes: 37 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    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 "#{try_sudo} touch #{File.join(current_path,'tmp','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
    end

    namespace :log do
    namespace :tail do
    desc "Tail no log da aplicação em produção"
    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