Created
March 13, 2014 20:45
-
-
Save jonstorer/9536635 to your computer and use it in GitHub Desktop.
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
# config valid only for Capistrano 3.1 | |
lock '3.1.0' | |
set :application, 'my-app' | |
set :repo_url, '[email protected]:my/repo.git' | |
set :user, 'deploy' | |
set :scm, :git | |
set :deploy_to, '/srv/www/my-app' | |
set :ssh_options, forward_agent: true | |
set :nvm_type, :user | |
set :nvm_node, 'v0.10.26' | |
set :nvm_map_bins, %w{npm forever} | |
set :linked_dirs, %w{log pid} | |
namespace :deploy do | |
desc 'Install dependencies' | |
task :install do | |
on roles(:app) do | |
within fetch(:release_path) do | |
execute :npm, 'install --production' | |
end | |
end | |
end | |
desc 'Restart application' | |
task :restart do | |
on roles(:app) do | |
within current_path do | |
if capture(:forever, :list).include?("#{current_path}/server.js") | |
execute :forever, :restart, "#{current_path}/server.js" | |
else | |
args = [ | |
"--append", | |
"-l #{current_path}/log/forever.log", | |
"-o #{current_path}/log/stdout.log", | |
"-e #{current_path}/log/stderr.log", | |
"--minUptime 2500", | |
"--spinSleepTime 2500", | |
] | |
execute :forever, :start, "#{args.join(' ')} #{current_path}/server.js" | |
end | |
end | |
end | |
end | |
after :updated, :install | |
after :publishing, :restart | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment