Capistrano 中的事务不起作用
Transaction in Capistrano not working
我在 Capistrano 中遇到事务问题。
我得到的错误是:
NoMethodError: undefined method `transaction' for #<SSHKit::Backend::Netssh:0x24
08b20>
Capistrano 版本为:3.4.0(Rake 版本:10.4.2)。
代码如下:
namespace :fun do
desc "Sample showing rescue, ensure, and on_rollback inside a transaction"
task :stuff do
on roles :all do
transaction do
on_rollback { logger.debug "my rollback" }
begin
logger.debug "main"
# Either run or run_locally will work the same
# run_locally "false"
run "false"
rescue => e
logger.debug "rescue #{e.class}"
raise e
ensure
logger.debug "ensure"
end
end
end
end
end
问题出在哪里?
Capistrano 3 中删除了 transaction
关键字。
开发者推荐使用新的流程控制来处理这种情况:https://github.com/capistrano/capistrano/issues/860
我在 Capistrano 中遇到事务问题。 我得到的错误是:
NoMethodError: undefined method `transaction' for #<SSHKit::Backend::Netssh:0x24
08b20>
Capistrano 版本为:3.4.0(Rake 版本:10.4.2)。
代码如下:
namespace :fun do
desc "Sample showing rescue, ensure, and on_rollback inside a transaction"
task :stuff do
on roles :all do
transaction do
on_rollback { logger.debug "my rollback" }
begin
logger.debug "main"
# Either run or run_locally will work the same
# run_locally "false"
run "false"
rescue => e
logger.debug "rescue #{e.class}"
raise e
ensure
logger.debug "ensure"
end
end
end
end
end
问题出在哪里?
Capistrano 3 中删除了 transaction
关键字。
开发者推荐使用新的流程控制来处理这种情况:https://github.com/capistrano/capistrano/issues/860