Skip to content

Instantly share code, notes, and snippets.

@alkema
Created July 9, 2011 20:01
Show Gist options
  • Save alkema/1073903 to your computer and use it in GitHub Desktop.
Save alkema/1073903 to your computer and use it in GitHub Desktop.
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "[email protected]:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
role :app, domain
role :web, domain
role :db, domain, :primary => true
namespace :deploy do
desc "Stop Forever"
task :stop do
run "sudo forever stopall"
end
desc "Start Forever"
task :start do
run "cd #{current_path} && sudo forever start app.js 80"
end
desc "Restart Forever"
task :restart do
stop
sleep 5
start
end
desc "Refresh shared node_modules symlink to current node_modules"
task :refresh_symlink do
run "rm -rf #{current_path}/node_modules && ln -s #{shared_path}/node_modules #{current_path}/node_modules"
end
desc "Install node modules non-globally"
task :npm_install do
run "cd #{current_path} && npm install"
end
end
after "deploy:update_code", "deploy:refresh_symlink", "deploy:npm_install"
@ryanray
Copy link

ryanray commented Nov 21, 2013

I posted a modified Capistrano 3 version here: https://gist.github.com/ryanray/7579912

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment