Browse Source

[COOK-1253] If a deployment fails and we have a previous version, roll back to that one.

Andrea Campi 12 years ago
parent
commit
9f3d960941
3 changed files with 3 additions and 0 deletions
  1. 1 0
      README.md
  2. 1 0
      providers/default.rb
  3. 1 0
      resources/default.rb

+ 1 - 0
README.md

@@ -79,6 +79,7 @@ Configuration of framework-specific aspects of the application are performed by
 - repository: the URL of the repository the application should be checked out from
 - revision: an identifier pointing to the revision that should be checkout out
 - deploy_key: the public key to use to access the repository via SSH
+- rollback\_on\_error: if true, exceptions during a deployment will be caught and a clean rollback to the previous version will be attempted; the exception will then be re-raised. Defaults to true; change it only if you know what you are doing
 - environment: a Hash of environment variables to set while running migrations
 - purge\_before\_symlink: an Array of paths (relative to the checkout) to remove before creating symlinks
 - create\_dirs\_before\_symlink: an Array paths (relative to the checkout) pointing to directories to create before creating symlinks

+ 1 - 0
providers/default.rb

@@ -128,6 +128,7 @@ def run_deploy(force = false)
     deploy_to new_resource.path
     ssh_wrapper "#{new_resource.path}/deploy-ssh-wrapper" if new_resource.deploy_key
     shallow_clone true
+    rollback_on_error new_resource.rollback_on_error
     all_environments = ([new_resource.environment]+new_resource.sub_resources.map{|res| res.environment}).inject({}){|acc, val| acc.merge(val)}
     environment all_environments
     migrate new_resource.migrate

+ 1 - 0
resources/default.rb

@@ -42,6 +42,7 @@ attribute :repository, :kind_of => String
 attribute :environment, :kind_of => Hash, :default => {}
 attribute :deploy_key, :kind_of => [String, NilClass], :default => nil
 attribute :force, :kind_of => [TrueClass, FalseClass], :default => false
+attribute :rollback_on_error, :kind_of => [TrueClass, FalseClass], :default => true
 attribute :purge_before_symlink, :kind_of => Array, :default => []
 attribute :create_dirs_before_symlink, :kind_of => Array, :default => []
 attribute :symlinks, :kind_of => Hash, :default => {}