Skip to content

Instantly share code, notes, and snippets.

@JoeStanton
Created January 25, 2013 10:13
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save JoeStanton/4633276 to your computer and use it in GitHub Desktop.
Save JoeStanton/4633276 to your computer and use it in GitHub Desktop.
Example Capistrano Deployment file for Node.js Projects
set :application, "SampleApp"
set :repository, "."
set :scm, :none
set :use_sudo, false
set :keep_releases, 5
#Use the copy method which will compress and scp the files
set :deploy_via, :copy
set :main_js, "app.js"
desc "Setup the Staging Environment"
task :staging do
set :branch, 'develop'
set :domain, '1.1.1.1'
set :user, 'ubuntu'
set :applicationdir, "/RedBadger/#{application}"
set :deploy_to, applicationdir
ssh_options[:keys] = ["deployment/staging.pem"]
server '1.1.1.1', :app, :primary => true
end
namespace :deploy do
desc "START the servers"
task :start, :roles => :app, :except => { :no_release => true } do
run "NODE_ENV=production forever start -m 20 #{applicationdir}/current/#{main_js}"
end
desc "STOP the servers"
task :stop, :roles => :app, :except => { :no_release => true } do
run "#{applicationdir} forever stop #{applicationdir}/current/#{main_js}"
end
desc "RESTART the servers"
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{applicationdir} forever restart #{applicationdir}/current/#{main_js}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment