Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Capistrano deploy script for deploying a Meteor app to multiple EC2 Ubuntu instances in parallel. Requires AWS EC2 Tools to be properly installed locally to work.
# The goal will be to ultimately make a Capistrano deploy script that does
# what is doing, but in parallel.
# This assumes you're using an AMI with Node, NPM, Meteor, Forever and
# optionally Meteorite installed
set :application, "YOUR_APP_NAME"
set :repository, "git@YOUR_GIT_REPO.git"
set :scm, :git
set :deploy_via, :remote_cache
set :user, "ubuntu"
set :deploy_to, "/home/ubuntu/www/APP_NAME"
set :use_sudo, false
set :default_environment, {
'ROOT_URL' => "http://APP_URL",
'PORT' => 9001
# This is a Rails-specific param, just want to disable the functionality
set :normalize_asset_timestamps, false
# This would be set to an array of dirs from your app that you want
# to persist across deploys
set :shared_children, %w(log)
# Set this to 'mrt' if you want to use Meteorite
set :meteor, "meteor"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
run_locally('ec2-describe-instances --filter "group-name=open" | grep | cut -f 4').each_line do |instance|
server instance, :app
namespace :deploy do
task :restart, :roles => :app do
run "forever stop --sourceDir #{current_path} bundle/main.js"
run "forever start --sourceDir #{current_path} -a -l #{shared_path}/log/production.log -e #{shared_path}/log/error.log bundle/main.js"
after "deploy:finalize_update" do
run "cd #{release_path}; #{meteor} bundle bundle.tgz"
run "cd #{release_path}; tar xvf #{File.join(release_path, "bundle.tgz")}"
run "rm -rf #{File.join(release_path, "bundle.tgz")}"
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.