Last active
October 25, 2015 21:14
-
-
Save olekenneth/a43b4daac080ca050992 to your computer and use it in GitHub Desktop.
Capistrano 2 deploy, forever and npm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :application, "application name" | |
set :repository, "[email protected]:olekenneth/repo.git" | |
set :deploy_to, "/var/www/#{application}" | |
set :log_to, "/var/log/node" | |
set :use_sudo, false | |
set :public_children, %w{} | |
role :web, "do" | |
namespace :deploy do | |
before "deploy:create_symlink", "deploy:npm" | |
desc "Install all dependencies from NPM" | |
task :npm do | |
run "cd #{release_path} && npm install" | |
end | |
before "deploy:restart", "deploy:empty_log" | |
desc "Empty error and output log on restart" | |
task :empty_log do | |
run "echo '' > #{log_to}/#{application}-err.log" | |
end | |
task :start do | |
run "forever start -a -l #{log_to}/#{application}.log -o #{log_to}/#{application}-out.log -e #{log_to}/#{application}-err.log --sourceDir \ | |
#{current_path} --uid #{application} index.js" | |
end | |
task :stop do | |
run "forever stop #{application}" | |
end | |
task :restart, :roles => :web, :except => { :no_release => true } do | |
run "forever restart #{application}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment