Created
January 16, 2010 08:40
-
-
Save Sutto/278739 to your computer and use it in GitHub Desktop.
Super Simple Git, Bundler and Unicorn deploys
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 | |
def config(key) | |
(@config ||= YAML.load_file("config/deploy.yml").symbolize_keys)[key.to_sym] | |
end | |
# Hooks as needed | |
task :local_before do | |
end | |
task :local_after do | |
end | |
task :remote_before do | |
end | |
task :remote_after do | |
end | |
# Actual deploy | |
desc "Runs a local deploy" | |
task :local do | |
Rake::Task["deploy:local_before"].invoke | |
system "gem bundle" | |
if File.exist?("tmp/pids/unicorn.pid") | |
begin | |
pid = File.read("tmp/pids/unicorn.pid").to_i | |
Process.kill(:USR2, pid) | |
rescue Errno::ENOENT, Errno::ESRCH | |
end | |
puts "Found pid, attempted to restart." | |
else | |
puts "Couldn't find a pid." | |
end | |
Rake::Task["deploy:local_after"].invoke | |
end | |
desc "Runs a remote deploy" | |
task :remote do | |
Rake::Task["deploy:remote_before"].invoke | |
system "ssh #{config(:user)}@#{config(:host)} 'cd #{config(:app)} && git pull && rake deploy:local RAILS_ENV=production'" | |
Rake::Task["deploy:remote_after"].invoke | |
end | |
end | |
task :deploy => "deploy:remote" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment