Skip to content

Instantly share code, notes, and snippets.

@bruschill
Last active January 2, 2016 09:49
Show Gist options
  • Save bruschill/8286093 to your computer and use it in GitHub Desktop.
Save bruschill/8286093 to your computer and use it in GitHub Desktop.
set :stage, :beta
set :branch, "development"
set :rails_env, "beta"
server 'ec2.us-west-2.compute.amazonaws.com',
user: 'rails',
port: '22000',
roles: :all
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
set :application, 'rails-api'
set :scm, :git
set :repo_url, 'git@bitbucket.org:company/repository'
set :rbenv_type, :user
set :rbenv_ruby, '1.9.3-p448'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all
set :deploy_to, '/var/www/rails-api'
set :keep_releases, 5
set :format, :pretty
set :log_level, :debug
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
after :finishing, 'deploy:cleanup'
end
DEBUG [bad40625] Running /usr/bin/env [ ! -d ~/.rbenv/versions/1.9.3-p448 ] on ec2.us-west-2.compute.amazonaws.com
DEBUG [bad40625] Command: [ ! -d ~/.rbenv/versions/1.9.3-p448 ]
##### potential issue? #####
DEBUG [bad40625] Finished in 1.422 seconds with exit status 1 (failed).
INFO [549ae205] Running /usr/bin/env mkdir -p /tmp/rails-api/ on ec2.us-west-2.compute.amazonaws.com
DEBUG [549ae205] Command: /usr/bin/env mkdir -p /tmp/rails-api/
INFO [549ae205] Finished in 0.131 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/rails-api/git-ssh.sh 0.0%
INFO Uploading /tmp/rails-api/git-ssh.sh 100.0%
INFO [2339ed71] Running /usr/bin/env chmod +x /tmp/rails-api/git-ssh.sh on ec2.us-west-2.compute.amazonaws.com
DEBUG [2339ed71] Command: /usr/bin/env chmod +x /tmp/rails-api/git-ssh.sh
INFO [2339ed71] Finished in 0.134 seconds with exit status 0 (successful).
DEBUG [a1e6e390] Running /usr/bin/env git ls-remote git@bitbucket.org:company/repository.git on ec2.us-west-2.compute.amazonaws.com
DEBUG [a1e6e390] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails-api/git-ssh.sh /usr/bin/env git ls-remote git@bitbucket.org:company/repository.git )
DEBUG [a1e6e390] 75645611eefef2fb62e5dd357fd8c8704e3aa57d HEAD
DEBUG [a1e6e390] 4a0aafc8aa8dfe13dee11a92cbc1affd55660078 refs/heads/capistrano-setup
DEBUG [a1e6e390] 75645611eefef2fb62e5dd357fd8c8704e3aa57d refs/heads/deployment
DEBUG [a1e6e390] 305df33f565c6679e60563215efe7263141a1b49 refs/heads/develop
DEBUG [a1e6e390] 8b6cad7424209b558f230022e37dd138c8c4ed44 refs/heads/development
DEBUG [a1e6e390] 49f7b56da527173161446fb5cce9086a79f43a71 refs/heads/feature/EncryptedFileController
DEBUG [a1e6e390] a66d985ebe8cc8da9251db843758d5b6957d07af refs/heads/feature/add_groups
DEBUG [a1e6e390] 142cba2cac83f4960c6789aca685390e1e3a9910 refs/heads/library_objects
DEBUG [a1e6e390] 75645611eefef2fb62e5dd357fd8c8704e3aa57d refs/heads/master
DEBUG [a1e6e390] 5538b5a5f3615bd64f014e3287f623aa8d591d51 refs/heads/mysql-switch
DEBUG [a1e6e390] e8ec0ae5e3beb4cad09290a6c79300f9f2f69776 refs/heads/progress-stats
DEBUG [a1e6e390] Finished in 2.627 seconds with exit status 0 (successful).
INFO [a1dfd7c5] Running /usr/bin/env mkdir -pv /var/www/rails-api/shared /var/www/rails-api/releases on ec2.us-west-2.compute.amazonaws.com
DEBUG [a1dfd7c5] Command: /usr/bin/env mkdir -pv /var/www/rails-api/shared /var/www/rails-api/releases
INFO [a1dfd7c5] Finished in 0.151 seconds with exit status 0 (successful).
DEBUG [beeb4927] Running /usr/bin/env [ -f /var/www/rails-api/repo/HEAD ] on ec2.us-west-2.compute.amazonaws.com
DEBUG [beeb4927] Command: [ -f /var/www/rails-api/repo/HEAD ]
DEBUG [beeb4927] Finished in 0.158 seconds with exit status 0 (successful).
INFO The repository mirror is at /var/www/rails-api/repo
DEBUG [eb1f3e7a] Running /usr/bin/env if test ! -d /var/www/rails-api/repo; then echo "Directory does not exist '/var/www/rails-api/repo'" 1>&2; false; fi on ec2.us-west-2.compute.amazonaws.com
DEBUG [eb1f3e7a] Command: if test ! -d /var/www/rails-api/repo; then echo "Directory does not exist '/var/www/rails-api/repo'" 1>&2; false; fi
DEBUG [eb1f3e7a] Finished in 0.146 seconds with exit status 0 (successful).
INFO [a39a5c51] Running /usr/bin/env git remote update on ec2.us-west-2.compute.amazonaws.com
DEBUG [a39a5c51] Command: cd /var/www/rails-api/repo && /usr/bin/env git remote update
DEBUG [a39a5c51] Fetching origin
INFO [a39a5c51] Finished in 2.258 seconds with exit status 0 (successful).
DEBUG [8233ea28] Running /usr/bin/env if test ! -d /var/www/rails-api/repo; then echo "Directory does not exist '/var/www/rails-api/repo'" 1>&2; false; fi on ec2.us-west-2.compute.amazonaws.com
DEBUG [8233ea28] Command: if test ! -d /var/www/rails-api/repo; then echo "Directory does not exist '/var/www/rails-api/repo'" 1>&2; false; fi
DEBUG [8233ea28] Finished in 0.135 seconds with exit status 0 (successful).
INFO [43ec1084] Running /usr/bin/env mkdir -p /var/www/rails-api/releases/20140106175209 on ec2.us-west-2.compute.amazonaws.com
DEBUG [43ec1084] Command: cd /var/www/rails-api/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails-api/git-ssh.sh /usr/bin/env mkdir -p /var/www/rails-api/releases/20140106175209 )
INFO [43ec1084] Finished in 0.141 seconds with exit status 0 (successful).
INFO [ef257c99] Running /usr/bin/env git archive development | tar -x -C /var/www/rails-api/releases/20140106175209 on ec2.us-west-2.compute.amazonaws.com
DEBUG [ef257c99] Command: cd /var/www/rails-api/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails-api/git-ssh.sh /usr/bin/env git archive development | tar -x -C /var/www/rails-api/releases/20140106175209 )
INFO [ef257c99] Finished in 0.152 seconds with exit status 0 (successful).
DEBUG [1e28a676] Running /usr/bin/env if test ! -d /var/www/rails-api/releases/20140106175209; then echo "Directory does not exist '/var/www/rails-api/releases/20140106175209'" 1>&2; false; fi on ec2.us-west-2.compute.amazonaws.com
DEBUG [1e28a676] Command: if test ! -d /var/www/rails-api/releases/20140106175209; then echo "Directory does not exist '/var/www/rails-api/releases/20140106175209'" 1>&2; false; fi
DEBUG [1e28a676] Finished in 0.139 seconds with exit status 0 (successful).
INFO [91a3d361] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=1.9.3-p448 ~/.rbenv/bin/rbenv exec bundle --gemfile /var/www/rails-api/releases/20140106175209/Gemfile --path /var/www/rails-api/shared/bundle --deployment --quiet --binstubs /var/www/rails-api/shared/bin --without development test on ec2.us-west-2.compute.amazonaws.com
DEBUG [91a3d361] Command: cd /var/www/rails-api/releases/20140106175209 && RBENV_ROOT=~/.rbenv RBENV_VERSION=1.9.3-p448 ~/.rbenv/bin/rbenv exec bundle --gemfile /var/www/rails-api/releases/20140106175209/Gemfile --path /var/www/rails-api/shared/bundle --deployment --quiet --binstubs /var/www/rails-api/shared/bin --without development test
INFO [91a3d361] Finished in 0.996 seconds with exit status 0 (successful).
##### potential issue? #####
WARN [SKIPPING] No Matching Host for /usr/bin/env if test ! -d /var/www/rails-api/releases/20140106175209; then echo "Directory does not exist '/var/www/rails-api/releases/20140106175209'" 1>&2; false; fi
##### potential issue? #####
WARN [SKIPPING] No Matching Host for RBENV_ROOT=~/.rbenv RBENV_VERSION=1.9.3-p448 ~/.rbenv/bin/rbenv exec bundle exec rake db:migrate
INFO [bdd5613d] Running /usr/bin/env rm -rf /var/www/rails-api/current on ec2.us-west-2.compute.amazonaws.com
DEBUG [bdd5613d] Command: /usr/bin/env rm -rf /var/www/rails-api/current
INFO [bdd5613d] Finished in 0.175 seconds with exit status 0 (successful).
INFO [a90d73bd] Running /usr/bin/env ln -s /var/www/rails-api/releases/20140106175209 /var/www/rails-api/current on ec2.us-west-2.compute.amazonaws.com
DEBUG [a90d73bd] Command: /usr/bin/env ln -s /var/www/rails-api/releases/20140106175209 /var/www/rails-api/current
INFO [a90d73bd] Finished in 0.139 seconds with exit status 0 (successful).
DEBUG [e2a53fb4] Running /usr/bin/env ls -x /var/www/rails-api/releases on ec2.us-west-2.compute.amazonaws.com
DEBUG [e2a53fb4] Command: /usr/bin/env ls -x /var/www/rails-api/releases
DEBUG [e2a53fb4] 20140106171124 20140106174513 20140106175209
DEBUG [e2a53fb4] Finished in 0.132 seconds with exit status 0 (successful).
DEBUG [831311ea] Running /usr/bin/env if test ! -d /var/www/rails-api/releases; then echo "Directory does not exist '/var/www/rails-api/releases'" 1>&2; false; fi on ec2.us-west-2.compute.amazonaws.com
DEBUG [831311ea] Command: if test ! -d /var/www/rails-api/releases; then echo "Directory does not exist '/var/www/rails-api/releases'" 1>&2; false; fi
DEBUG [831311ea] Finished in 0.153 seconds with exit status 0 (successful).
INFO [01fe6c31] Running /usr/bin/env echo "Branch development deployed as release 20140106175209 by bruschill; " >> /var/www/rails-api/revisions.log on ec2.us-west-2.compute.amazonaws.com
DEBUG [01fe6c31] Command: echo "Branch development deployed as release 20140106175209 by bruschill; " >> /var/www/rails-api/revisions.log
INFO [01fe6c31] Finished in 0.142 seconds with exit status 0 (successful).
server {
listen 80;
server_name ec2.us-west-2.compute.amazonaws.com;
root /var/www/rails-api/public;
passenger_enabled on;
rails_env beta;
}
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/rails/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/passenger-4.0.29;
passenger_ruby /home/rails/.rbenv/versions/1.9.3-p448/bin/ruby;
include mime.types;
default_type application/octet-stream;
include servers/*.conf;
sendfile on;
keepalive_timeout 65;
gzip on;
client_max_body_size 4M;
client_body_buffer_size 128k;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment