lib/shuttle/strategy.rb in shuttle-deploy-0.2.0.beta4 vs lib/shuttle/strategy.rb in shuttle-deploy-0.2.0.beta5
- old
+ new
@@ -24,10 +24,12 @@
link_release
cleanup_releases
end
def rollback
+ execute_hook(:before_rollback)
+
if last_version == 0
error "There are no releases to rollback to"
end
release = available_releases.select { |v| v == last_version-1 }.first
@@ -39,15 +41,19 @@
if ssh.run("ln -s #{deploy_path}/releases/#{release} #{current_path}").failure?
error "Unable to create symlink to current path"
end
- ssh.run("echo #{version} > #{version_path}")
+ ssh.run("echo #{release} > #{version_path}")
+ ssh.run("rm -rf #{deploy_path}/releases/#{last_version}")
+
log "Rolled back to release v#{release}"
else
error "There are no older releases"
end
+
+ execute_hook(:after_rollback)
end
def update_code
if config.app.svn
return update_code_svn
@@ -268,21 +274,9 @@
result = ssh.run(%{diff -r #{current_path}/#{path} #{release_path}/#{path} 2>/dev/null})
result.success? ? false : true
end
def execute_commands(commands=[], allow_failures=false)
- commands.flatten.compact.uniq.each do |cmd|
- log %{Executing "#{cmd.strip}"}
- command = cmd
- command = "cd #{release_path} && #{command}" if ssh.directory_exists?(release_path)
-
- result = ssh.run(command)
-
- if result.failure? && allow_failures == false
- error "Failed: #{result.output}"
- else
- stream_output(result.output)
- end
- end
+ Shuttle::Hook.new(self).run(commands, allow_failures)
end
end
end
\ No newline at end of file