Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
d4be4st committed Mar 9, 2015
1 parent f6e414e commit 572f40e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/mina/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@
#{echo_cmd %{ls -1d [0-9]* | sort -rn | tail -n $remove | xargs rm -rf {}}}
}
end

# ### deploy:rollback
# Rollbacks the latest release.
#
# By default, the last 5 releases are kept on each server (though you can
# change this with the keep_releases setting). All other deployed revisions
# are removed from the servers."
desc "Rollbacks 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 -Art "#{deploy_to}/releases" | 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 (current release)
queue %[echo -n "-----> Deleting current release: "]
queue %[ls -Art "#{deploy_to}/releases" | sort | tail -n 1]
queue! %[ls -Art "#{deploy_to}/releases" | sort | tail -n 1 | xargs -I active rm -rf "#{deploy_to}/releases/active"]
end
end

# ### setup
Expand Down

0 comments on commit 572f40e

Please sign in to comment.