Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make deploy:cleanup work with multi-host configuration

  • Loading branch information...
commit a35da47da333f0518d23d2f6d2288a618b4d8aff 1 parent 4f40127
Phil Rosenstein philrosenstein authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/capistrano/recipes/deploy.rb
10 lib/capistrano/recipes/deploy.rb
View
@@ -409,14 +409,14 @@ def try_runner(*args)
will use sudo to clean up the old releases, but if sudo is not available \
for your environment, set the :use_sudo variable to false instead.
DESC
- task :cleanup, :except => { :no_release => true } do
+ task :cleanup, :roles => [:app, :web, :db], :except => { :no_release => true } do
count = fetch(:keep_releases, 5).to_i
- if count >= releases.length
+ local_releases = capture("ls -xt #{releases_path}").split.reverse
+ if count >= local_releases.length
logger.important "no old releases to clean up"
else
- logger.info "keeping #{count} of #{releases.length} deployed releases"
-
- directories = (releases - releases.last(count)).map { |release|
+ logger.info "keeping #{count} of #{local_releases.length} deployed releases"
+ directories = (local_releases - local_releases.last(count)).map { |release|
File.join(releases_path, release) }.join(" ")
try_sudo "rm -rf #{directories}"
Please sign in to comment.
Something went wrong with that request. Please try again.