Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed some multi-instance bugs, especially the use of capture() which…

… only executes it's command on one server (it should only be used to get some info from the server, not for things that should have side effects).
  • Loading branch information...
commit 0904a9804bc136d92a4b031eb0024709e3a93cb1 1 parent 9fa1790
@pauldowman authored
View
3  lib/ec2onrails/capistrano_utils.rb
@@ -31,6 +31,9 @@ def hostnames_for_role(role_sym, options = {})
# Like the capture method, but does not print out error stream and swallows
# an exception if the process's exit code != 0
+ # NOTE: this only executes on the first server in the list. Don't use this
+ # to execute a task that has a side-effect (i.e. something that needs to be
+ # run on all servers).
def quiet_capture(command, options={})
output = ""
invoke_command(command, options.merge(:once => true)) do |ch, stream, data|
View
10 lib/ec2onrails/recipes/server.rb
@@ -273,7 +273,7 @@
# very quickly before the sudo is called
# run "cd #{release_path} && rake RAILS_ENV=#{rails_env} -T 1>/dev/null && sudo rake RAILS_ENV=#{rails_env} gems:install"
allow_sudo do
- output = quiet_capture "cd #{release_path} && rake RAILS_ENV=#{rails_env} db:version > /dev/null 2>&1 || sudo rake RAILS_ENV=#{rails_env} gems:install"
+ output = run "cd #{release_path} && rake RAILS_ENV=#{rails_env} db:version > /dev/null 2>&1 || sudo rake RAILS_ENV=#{rails_env} gems:install"
puts output
end
end
@@ -480,9 +480,11 @@ def allow_sudo
if @within_sudo > 1
yield if block_given?
true
- elsif capture("groups").split.include?("rootequiv")
- yield if block_given?
- false
+ # The following can break if using multiple instances and a deploy was killed partway.
+ # Disabled for now.
+ # elsif capture("groups").split.include?("rootequiv")
+ # yield if block_given?
+ # false
else
begin
# need to cheat and temporarily set the user to ROOT so we
Please sign in to comment.
Something went wrong with that request. Please try again.