We're using Capistrano/Webistrano (with Lee Hambley's railsless-deploy gem) to push our PHP application to production servers. I have some custom tasks that get run during various parts of the deploy process.
As an example, I have tasks that attempt to stop and restart a jetty solr instance. However, sometimes this bit fails during th开发者_高级运维e deploy, so Capistrano rolls back the entire deploy and reverts back to the previous revision. This is a pain. :-)
I'd like to tell Capistrano to ignore the return result of these tasks, so if they fail, Capistrano continues on it's way and finishes the deploy anyway. It's very easy for me to ssh to the server after the fact and properly kill and restart the solr instance, rather than having to do a complete deploy again.
Here is some relevant parts of the deploy script:
before "deploy:symlink", :solr_kill
after "deploy:symlink", :solr_start, :solr_index
task :solr_kill do
run "cd #{current_path}/Base ; #{sudo} phing solr-kill"
end
task :solr_start do
run "cd #{current_path}/Base ; #{sudo} phing solr-start"
run "sleep 10"
end
task :solr_index do
run "#{sudo} #{current_path}/Base/Bin/app.php cron run solr_index_cron"
end
from the Capistrano Task docs there is a config you can add to if there is an error, to continue.
task :solr_start, :on_error => :continue do
# your code here
end
Just add that to each task you want to ignore errors and continue. Though, the best possible thing is to see if you can figure out what is causing the failure and have the restart command be more robust to really restart it. I only say this, since when you try to hand off the script to someone else, they might not know exactly how to tell if it restarted correctly.
精彩评论