Skip to content

Commit

Permalink
put the use_sudo toggle back in
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6491 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Mar 29, 2007
1 parent a2a8354 commit 523021d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/capistrano/recipes/deploy.rb
Expand Up @@ -46,6 +46,8 @@
set(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
set(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }

set(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }

namespace :deploy do
desc "Deploys your project. This calls both `update' and `restart'. Note that \
this will generally only work for applications that have already been deployed \
Expand Down Expand Up @@ -167,11 +169,11 @@
script under the current path. By default, this will be invoked via sudo, but \
if you are in an environment where sudo is not an option, or is not allowed, \
you can indicate that restarts should use `run' instead by setting the \
`restart_via' variable:
`use_sudo' variable to false:
set :restart_via, :run"
set :use_sudo, false"
task :restart, :roles => :app, :except => { :no_release => true } do
invoke_command "#{current_path}/script/process/reaper", :via => fetch(:restart_via, :sudo)
invoke_command "#{current_path}/script/process/reaper", :via => run_method
end

desc "Rolls back to the previously deployed version. The `current' symlink will \
Expand Down Expand Up @@ -240,7 +242,7 @@
server (though you can change this with the keep_releases variable). All other \
deployed revisions are removed from the servers. By default, this will use \
sudo to clean up the old releases, but if sudo is not available for your \
environment, set the :cleanup_via variable to :run instead."
environment, set the :use_sudo variable to false instead."
task :cleanup, :except => { :no_release => true } do
count = fetch(:keep_releases, 5).to_i
if count >= releases.length
Expand All @@ -251,7 +253,7 @@
directories = (releases - releases.last(count)).map { |release|
File.join(releases_path, release) }.join(" ")

invoke_command "rm -rf #{directories}", :via => fetch(:cleanup_via, :sudo)
invoke_command "rm -rf #{directories}", :via => run_method
end
end

Expand Down

0 comments on commit 523021d

Please sign in to comment.