capistrano on davidchua https://dchua.com/tags/capistrano/ Recent content in capistrano on davidchua Hugo -- gohugo.io en-us Thu, 29 Aug 2013 00:00:00 +0000 Properly using SSH Agent Forwarding in Capistrano https://dchua.com/posts/2013-08-29-properly-using-ssh-agent-forwarding-in-capistrano/ Thu, 29 Aug 2013 00:00:00 +0000 https://dchua.com/posts/2013-08-29-properly-using-ssh-agent-forwarding-in-capistrano/ You’ve probably seen this in your capistrano deploy script. # /config/deploy.rb set :ssh_options, { :forward_agent => true } SSH Agent Forwarding is a great way to keep SSH keys manageable as it allows the deployment server to use your own local private key to authenticate to the git repository, instead of having to give your deployment server access to your git repository. Github has an awesome article explaining this. My tl;dr version: Tail Rails Production Logs from Capistrano https://dchua.com/posts/2013-08-21-tail-rails-production-logs-from-capistrano/ Wed, 21 Aug 2013 00:00:00 +0000 https://dchua.com/posts/2013-08-21-tail-rails-production-logs-from-capistrano/ Found this nifty snippet today which would allow you to tail your production logs without leaving your local terminal. # capistrano desc "tail production log files" task :tail_logs, :roles => :app do trap("INT") { puts 'Interupted'; exit 0; } run "tail -f #{shared_path}/log/production.log" do |channel, stream, data| puts # for an extra line break before the host name puts "#{channel[:host]}: #{data}" break if stream == :err end end I put mine in the ‘rails’ namespace, so all I have to do is a nice: Loading 'deploy/assets' in Capistrano, automatically precompiles:assets https://dchua.com/posts/2013-07-14-loading-deployassets-in-capistrano-automatically-precompilesassets/ Sun, 14 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-14-loading-deployassets-in-capistrano-automatically-precompilesassets/ Something that I’ve just figured out after tinkering for a couple of hours. Hope this will save someone else some trouble. So I’m running my own custom Capistrano script that on fresh deploy setup a symlink of database.yml on the app instance, so that you don’t need to check in your database.yml file. So in my config/deploy.rb, I have something like: after 'deploy:update_code', 'deploy:symlink_db', 'deploy:assets:precompile' . . . . desc " Deploying Node.JS on Nginx with Capistrano/Capper https://dchua.com/posts/2013-05-28-deploying-node-js-on-nginx-with-capistranocapper/ Tue, 28 May 2013 00:00:00 +0000 https://dchua.com/posts/2013-05-28-deploying-node-js-on-nginx-with-capistranocapper/ The other day on a single-day internal hackathon, together with Ernest and the rest of the One Cent Movement guys, we decided to do up an internal check-in mobile webapp where we can see where each of us were at anytime of the day. This is a simple guide to deploy your node.js app onto a production server. Which in my case is an Amazon EC2 m1.small instance. Pre-requsite: NPM is assumed to be the defacto package manager. Speed up assets:precompile in Capistrano https://dchua.com/posts/2013-03-02-assets-precompile-passenger/ Sat, 02 Mar 2013 00:00:00 +0000 https://dchua.com/posts/2013-03-02-assets-precompile-passenger/ Note to self. In order to speed up assets:precompile on passenger production, add the following to config/deploy.rb: namespace :deploy do namespace :assets do task :precompile, :roles => :web, :except => { :no_release => true } do from = source.next_revision(current_revision) if capture("cd #{latest_release}&& #{source.local.log(from)}vendor/assets/ app/assets/ | wc -l").to_i > 0 run %Q{cd #{latest_release}&& #{rake}RAILS_ENV=#{rails_env}#{asset_env}assets:precompile} else logger.info "Skipping asset pre-compilation because there were no asset changes" end end end end Alt: set :max_asset_age, 2 ## Set asset age in minutes to test modified date against.