Skip to content

Instantly share code, notes, and snippets.

@alkema
Created July 9, 2011 20:01
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • 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, "git@github.com: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"
@jfrux
Copy link

jfrux commented Oct 14, 2013

Any update of this to Capistrano v3.x?

@mikebevz
Copy link

mikebevz commented Nov 3, 2013

Capistrano 3 update would be really great

@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