Created
January 5, 2012 02:53
-
-
Save syshen/1563490 to your computer and use it in GitHub Desktop.
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
namespace :deploy do | |
task :default do | |
transaction do | |
deploy.git_log | |
deploy.update | |
deploy.setup | |
deploy.restart | |
end | |
end | |
desc "Send email notification" | |
task :send_notification do | |
Notifier.deploy_notification(self).deliver | |
end | |
after :deploy do | |
send_notification | |
end | |
task :git_log, :roles => :web do | |
local_sha = `git rev-parse --verify HEAD` | |
remote_sha = capture(:stdout) { stream("cd /home/code/current ; git rev-parse --verify HEAD") } | |
puts "#{remote_sha.strip}" | |
git_log = `/usr/bin/git log #{remote_sha.strip}..#{local_sha.strip} --pretty=format:'%h from %an, %ar, message: %s'` | |
puts git_log | |
set :history, git_log.gsub(/\n/, '<br>') | |
end | |
task :setup_web, :roles => :web do | |
# web role initiate | |
end | |
task :setup_ap, :roles => [:worker, :scheduler, :batch] do | |
# web roles initiate | |
end | |
task :setup do | |
setup_web | |
setup_ap | |
end | |
task :start_web, :roles => :web do | |
# start web | |
end | |
task :start_worker, :roles => :worker do | |
# start worker | |
end | |
task :start_scheduler, :roles => :scheduler do | |
# start scheduler | |
end | |
task :start_batch, :roles => :batch do | |
# start batch | |
end | |
task :start do | |
start_web | |
start_worker | |
start_scheduler | |
start_batch | |
end | |
task :stop_web, :roles => :web do | |
# stop web | |
end | |
task :stop_ap, :roles => [:worker, :scheduler, :batch] do | |
# stop ap | |
end | |
task :stop do | |
stop_web | |
stop_ap | |
end | |
task :restart do | |
stop | |
start | |
end | |
before 'deploy:restart' do | |
run "#{sudo :as => 'root'} monit stop all; true" | |
end | |
after 'deploy:restart' do | |
run "#{sudo :as => 'root'} monit start all; true" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment