Created
November 1, 2011 22:21
-
-
Save meritt/1332133 to your computer and use it in GitHub Desktop.
Capistrano config for NodeJS application
This file contains 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, "simonenko.su" | |
set :node_file, "server.coffee" | |
set :host, "178.79.189.200" | |
set :repository, "[email protected]:meritt/simonenko.su.git" | |
set :user, "root" | |
set :admin_runner, "www" | |
set :scm, :git | |
set :branch, "master" | |
set :deploy_via, :remote_cache | |
set :deploy_to, "/usr/www/#{application}" | |
set :keep_releases, 4 | |
role :app, host | |
namespace :deploy do | |
desc "Start application with forever" | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "forever start -c coffee #{current_path}/#{node_file}" | |
end | |
desc "Stop application" | |
task :stop, :roles => :app, :except => { :no_release => true } do | |
run "forever stop #{current_path}/#{node_file}" | |
end | |
desc "Restart application" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
stop | |
sleep 1 | |
start | |
end | |
desc "Install npm modules" | |
task :npm_install do | |
run "cd #{release_path} && npm link" | |
end | |
desc "Update node_modules symlink" | |
task :npm_update_symlink do | |
run "rm -rf #{release_path}/node_modules" | |
run "ln -s #{shared_path}/node_modules #{release_path}/node_modules" | |
end | |
desc "Update access to application" | |
task :final_options, roles => :app do | |
run "chown -R #{admin_runner}:#{admin_runner} #{deploy_to}" | |
run "chmod 777 #{release_path}/cache" | |
end | |
task :symlink_configs, :roles => :app do | |
%w[app_config.yml].each do |f| | |
run "ln -sf #{shared_path}/config/#{f} #{release_path}/config/#{f}" | |
end | |
end | |
desc "Create folders for nodejs application" | |
task :setup_for_nodejs, :roles => :app do | |
run "mkdir -p #{deploy_to}" | |
run "mkdir -p #{shared_path}/node_modules" | |
run "chown -R #{admin_runner}:#{admin_runner} #{deploy_to}" | |
end | |
end | |
before 'deploy:setup', 'deploy:setup_for_nodejs' | |
after "deploy:finalize_update", "deploy:cleanup", "deploy:symlink_configs", "deploy:final_options" | |
after "deploy:update_code", "deploy:npm_update_symlink", "deploy:npm_install" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Подробнее о том как работать с Capistrano для NodeJS проектов здесь: blog.simonenko.su