Created
April 11, 2014 18:46
-
-
Save patricksimpson/10491470 to your computer and use it in GitHub Desktop.
Mina Rollback
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
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 "echo `cat #{deploy_to}/last_version` | ruby -e 'p gets.to_i-1'" | |
queue! "echo `cat #{deploy_to}/last_version` | ruby -e 'p gets.to_i-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 "echo `cat #{deploy_to}/last_version`" | |
queue! "echo `cat #{deploy_to}/last_version` | xargs -I active rm -rf #{deploy_to}/releases/active" | |
# Update the "last_version" file | |
queue %[echo -n "-----> Updating last_version file. "] | |
queue! "mv #{deploy_to}/last_version #{deploy_to}/del_version" | |
queue! "echo `cat #{deploy_to}/del_version` | ruby -e 'p gets.to_i-1' > #{deploy_to}/last_version" | |
queue! "rm #{deploy_to}/del_version" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires ruby on the server, this is almost always going to be the case with our build process.