lib/alpha_omega/deploy.rb in alpha_omega-0.0.129 vs lib/alpha_omega/deploy.rb in alpha_omega-0.0.130
- old
+ new
@@ -256,10 +256,16 @@
strategy.deploy!
bundle
cook
end
+ task :symlink_next, :except => { :no_release => true } do
+ if releases.length >= 2
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{latest_release} #{next_path}"
+ end
+ end
+
desc <<-DESC
Updates the symlink to the most recently deployed version. Capistrano works \
by putting each new release of your application in its own directory. When \
you deploy a new version, this task's job is to update the `current' symlink \
to point at the new version. You will rarely need to call this task \
@@ -269,20 +275,23 @@
DESC
task :symlink, :except => { :no_release => true } do
if releases.length > 0
on_rollback do
if previous_release
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} rm -fv #{previous_path} #{next_path}; true"
run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{previous_release} #{current_path}; true"
else
logger.important "no previous release to rollback to, rollback of symlink skipped"
end
end
if releases.length == 1
run "[[ $(readlink #{current_path} 2>&-) = #{latest_release} ]] || #{try_sudo} ln -vsnf #{latest_release} #{current_path}"
else
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} rm -fv #{previous_path} #{next_path}"
run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{latest_release} #{current_path}"
+ run "#{File.dirname(current_path).index(deploy_to) == 0 ? "" : try_sudo} ln -vsnf #{previous_release} #{previous_path}"
end
system "#{figlet} -w 200 #{release_name} activated"
end
end
@@ -363,9 +372,10 @@
ever) need to be called directly.
DESC
task :revision, :except => { :no_release => true } do
if previous_release
system "#{figlet} -w 200 on #{previous_release}"
+ run "rm -fv #{previous_path} #{next_path}"
run "ln -vsnf #{previous_release} #{current_path}"
else
abort "could not rollback the code because there is no prior release"
end
end