Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capistrano deploy script for deploying multiple app instances of a Meteor app to a single private VPS on different ports.
# This deploy script takes a parameter to define the number of instances to deploy (default is 1)
# ex: cap deploy -s instances=3
set :application, "YOUR_APP_NAME"
set :repository, "git@YOUR_GIT_REPOT.git"
set :scm, :git
set :deploy_via, :remote_cache
set :user, "deploy"
set :deploy_to, "/home/deploy/www/#{application}"
set :use_sudo, false
set :default_environment, {
'ROOT_URL' => "YOUR_APP_URL",
'MONGO_URL' => "mongodb://<user>:<pass>@<mongoserver:port>/<db_name>",
'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 'meteor' if you don't use Meteorite
set :meteor, "mrt"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
server "SERVER_IP / URL", :app
namespace :deploy do
task :restart, :roles => :app do
run "forever stop --sourceDir #{current_path} bundle/main.js"
if instances = fetch(:instances, 1)
(1..instances).each do |i|
run "forever start --sourceDir #{current_path} -a -l #{shared_path}/log/production.log -e #{shared_path}/log/error.log bundle/main.js", :env => { 'PORT' => i + 9000 }
end
end
end
end
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")}"
end
# 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.