mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Added a cleanup task to remove unused releases from the deployment directory
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3372 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
829fb7d8ed
commit
c3c3b8ab4a
2 changed files with 21 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Added a cleanup task to remove unused releases from the deployment directory
|
||||||
|
|
||||||
* Allow password to be reentered on sudo if it was entered incorrectly
|
* Allow password to be reentered on sudo if it was entered incorrectly
|
||||||
|
|
||||||
* Use && as the command separator for the checkouts, so that errors are caught early.
|
* Use && as the command separator for the checkouts, so that errors are caught early.
|
||||||
|
|
|
@ -144,7 +144,7 @@ end
|
||||||
|
|
||||||
desc <<-DESC
|
desc <<-DESC
|
||||||
Similar to deploy, but it runs the migrate task on the new release before
|
Similar to deploy, but it runs the migrate task on the new release before
|
||||||
updating the symlink. (Note that the update in this case is not atomic,
|
updating the symlink. (Note that the update in this case it is not atomic,
|
||||||
and transactions are not used, because migrations are not guaranteed to be
|
and transactions are not used, because migrations are not guaranteed to be
|
||||||
reversible.)
|
reversible.)
|
||||||
DESC
|
DESC
|
||||||
|
@ -185,3 +185,21 @@ desc "Update the currently released version of the software directly via an SCM
|
||||||
task :update_current do
|
task :update_current do
|
||||||
source.update(self)
|
source.update(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc <<-DESC
|
||||||
|
Removes unused releases from the releases directory. By default, the last 5
|
||||||
|
releases are retained, but this can be configured with the 'keep_releases'
|
||||||
|
variable.
|
||||||
|
DESC
|
||||||
|
task :cleanup do
|
||||||
|
count = (self[:keep_releases] || 5).to_i
|
||||||
|
if count >= releases.length
|
||||||
|
logger.important "no old releases to clean up"
|
||||||
|
else
|
||||||
|
logger.info "keeping #{count} of #{releases.length} deployed releases"
|
||||||
|
keepers = (releases - releases.last(count)).map { |release|
|
||||||
|
File.join(releases_path, release) }.join(" ")
|
||||||
|
|
||||||
|
sudo "rm -rf #{keepers}"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue