【发布时间】:2014-01-14 20:59:23
【问题描述】:
在 Capistrano 2.x 中,您可以简单地添加 :on_error => :continue 像这样:
task :bad_script, :on_error => :continue do
my_error = capture('/path/to/tomcat/shutdown.sh')
end
我在 Capistrano 3.x 或 ssh-kit(底层通信)中看不到任何方法。任何帮助将不胜感激。
task :bad_script do
server_is_down
on roles :all do
begin
server_is_down = capture('/path/to/tomcat/shutdown.sh')
rescue
#do something if server_is_down has the correct text
end
end
end
end
我尝试在开始/救援块中包围新方法,但这只会阻止它出错,但不会返回错误的输出。
我仍然想知道如何做到这一点,但我想出了一种方法来解决我的一个案例需要它,那就是如果它失败,只需设置服务器关闭。
task :bad_script do
server_is_down = false
on roles :all do
begin
execute('/path/to/tomcat/shutdown.sh')
rescue
server_is_down = true
end
end
end
end
这是假设它仅在关机发生时出错。
【问题讨论】:
标签: ruby deployment capistrano capistrano3 sshkit