Created
July 28, 2014 01:23
-
-
Save luizpicolo/dbdff3ce8149798b265b to your computer and use it in GitHub Desktop.
Mina Deploy RollBack
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
desc "Rolls back the latest release" | |
task :rollback => :environment do | |
queue! %[echo "-----> Rolling back to previous release for instance: #{domain}"] | |
# Delete existing sym link and create a new symlink pointing to the previous release | |
queue %[echo -n "-----> Creating new symlink from the previous release: "] | |
queue %[ls "#{deploy_to}/releases" -Art | sort | tail -n 2 | head -n 1] | |
queue! %[ls -Art "#{deploy_to}/releases" | sort | tail -n 2 | head -n 1 | xargs -I active ln -nfs "#{deploy_to}/releases/active" "#{deploy_to}/current"] | |
# Remove latest release folder (active release) | |
queue %[echo -n "-----> Deleting active release: "] | |
queue %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1] | |
queue! %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1 | xargs -I active rm -rf "#{deploy_to}/releases/active"] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you reach more then 9 releases you may run into trouble with sort, it may sort your numbers like strings. I changed
sort
tosort -n
.