Skip to content

Instantly share code, notes, and snippets.

@DevanB
Created January 13, 2014 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevanB/8403955 to your computer and use it in GitHub Desktop.
Save DevanB/8403955 to your computer and use it in GitHub Desktop.
set :application, 'liveinbirmingham'
set :deploy_user, 'deploy'
#set repo details
# set :scm, :git
set :repo_url, 'git@github.com:DevanB/LIveInBham.git'
set :full_app_name, "#{fetch(:application)}"
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
#set rbenv
set :rbenv_type, :system
set :rbenv_ruby, '2.0.0-p353'
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}
# how many old releases do we want to keep
set :keep_releases, 5
# files we want symlinking to specific entires in shared.
set :linked_files, %w{config/database.yml config/application.yml}
# dirs we want symlinking to shared
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
# what specs should be run before deployment is allowed to continue, see lib/capistrano/tasks/run_tests.cap
set :tests, []
# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap for details of operations
set(:config_files, %w(
nginx.conf
application.yml
database.example.yml
log_rotation
unicorn.rb
unicorn_init.sh
))
# which config files should be made executable after copying by deploy:setup_config
set(:executable_config_files, %w(
unicorn_init.sh
))
# files which need to be symlinked to other parts of the filesystem. For example
# nginx virtualhosts, log rotation, inits scripts, etc.
set(:symlinks, [
{
source: "/deploy/shared/nginx.conf",
link: "/etc/nginx/sites-enabled/#{fetch(:full_app_name)}"
},
{
source: "/deploy/shared/unicorn_init.sh",
link: "/etc/init.d/unicorn_#{fetch(:full_app_name)}"
},
{
source: "/deploy/shared/log_rotation",
link: "/etc/logrotate.d/#{fetch(:full_app_name)}"
}
])
# this:
# http://www.capistranorb.com/documentation/getting-started/flow/
# is worth reading for a quick overview of what tasks are called
# and when for `cap stage deploy`
namespace :deploy do
# make sure we're deploying what we think we're deploying
before :deploy, "deploy:check_revision"
# only allow a deploy with passing tests to deployed
before :deploy, "deploy:run_tests"
# compile assets locally then rsync
after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
after :finishing, 'deploy:cleanup'
end
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# set :format, :pretty
set :log_level, :debug
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
** Invoke deploy:compile_assets_locally (first_time)
** Execute deploy:compile_assets_locally
INFO [e31c0b61] Running /usr/bin/env bundle exec rake assets:precompile on
DEBUG [e31c0b61] Command: bundle exec rake assets:precompile
INFO [e31c0b61] Finished in 7.351 seconds with exit status 0 (successful).
INFO [9593d948] Running /usr/bin/env rsync -av ./public/assets/ deploy@127.0.0.1:/home/deploy/apps/liveinbirmingham/releases/20140113170729/public/assets/; on
DEBUG [9593d948] Command: rsync -av ./public/assets/ deploy@127.0.0.1:/home/deploy/apps/liveinbirmingham/releases/20140113170729/public/assets/;
Password:
Password:
Password:
cap aborted!
rsync -av ./public/assets/ deploy@127.0.0.1:/home/deploy/apps/liveinbirmingham/releases/20140113170729/public/assets/; stdout: Nothing written
rsync -av ./public/assets/ deploy@127.0.0.1:/home/deploy/apps/liveinbirmingham/releases/20140113170729/public/assets/; stderr: Permission denied (publickey,keyboard-interactive).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:49:in `block in _execute'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:36:in `tap'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:36:in `_execute'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:25:in `execute'
/Users/dbeitel/Documents/Projects/LIveInBham/lib/capistrano/tasks/compile_assets_locally.cap:9:in `block (4 levels) in <top (required)>'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:13:in `instance_exec'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/local.rb:13:in `run'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/dsl.rb:12:in `run_locally'
/Users/dbeitel/Documents/Projects/LIveInBham/lib/capistrano/tasks/compile_assets_locally.cap:8:in `block (3 levels) in <top (required)>'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/dbeitel/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:compile_assets_locally
set :stage, :production
set :branch, "master"
# used in case we're deploying multiple versions of the same
# app side by side. Also provides quick sanity checks when looking
# at filepaths
server '127.0.0.1:2222', user: 'deploy', roles: %w{web app db}, primary: true
# dont try and infer something as important as environment from
# stage name.
set :rails_env, :production
# number of unicorn workers, this will be reflected in
# the unicorn.rb and the monit configs
set :unicorn_worker_count, 5
# whether we're using ssl or not, used for building nginx
# config file
set :enable_ssl, false
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# role :app, %w{deploy@127.0.0.1}
# role :web, %w{deploy@127.0.0.1}
# role :db, %w{deploy@127.0.0.1}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
# fetch(:default_env).merge!(rails_env: :production)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment