当我定义要在多个远程服务器上运行的任务时,如果该任务在服务器1上运行并因错误而退出,Fabric将停止并中止该任务。但是我想让fabric忽略这个错误并在下一个服务器上运行这个任务。我怎样才能做到这一点?
例如:
$ fab site1_service_gw
[site1rpt1] Executing task 'site1_service_gw'
[site1fep1] run: echo 'Nm123!@#' | sudo -S route
[site1fep1] err:
[site1fep1] err: We trust you have received the usual lecture from the local System
[site1fep1] err: Administrator. It usually boils down to these three things:
[site1fep1] err:
[site1fep1] err: #1) Respect the privacy of others.
[site1fep1] err: #2) Think before you type.
[site1fep1] err: #3) With great power comes great responsibility.
[site1fep1] err: root's password:
[site1fep1] err: sudo: route: command not found
Fatal error: run() encountered an error (return code 1) while executing 'echo 'Nm123!@#' | sudo -S route '
Aborting.
来自the docs:
看起来您可以使用^{} context manager 对忽略错误的位置进行细粒度控制,如下所示:
从Fabric 1.5开始,有一个ContextManager可以简化这一过程:
更新:我使用以下代码再次确认这在ipython中有效。
也可以将整个脚本的“仅警告”设置设置为true
相关问题 更多 >
编程相关推荐