本文共 791 字,大约阅读时间需要 2 分钟。
Capistrano 灰常好用。 不过有几个常用的用法还是要留意一下: 1. 总览:$ cap --help2. 使用logger,特别是在其他语言调用CAP时,非常有用(例如被fabric 调用):
$ cap setup --logger STDOUT3. 使用变量, 要记得: 使用@. . 例如,我们要设置 "deploy_type" 这个变量:
$ cap say_hi --set-before deploy_type=staging然后在 config/deploy.rb 中这样使用:
DEFAULT_TYPE = "stable" # deploy_type 仅仅在 begin 这个区域中生效, 在rescue, ensure中都不行。 begin deploy_type puts "deploy_type was set successfully" @deploy_type = deploy_type rescue Exception => e puts "deploy_type not set, use default: #{DEFAULT_TYPE}" deploy_type = DEFAULT_TYPE @deploy_type = deploy_type end task :say_hi do puts "hihihi, var_deploy_type: #{@deploy_type}" end输出:
deploy_type was set successfully ============= DEPLOY_PATH: /rails_apps/babble_portal/cutting_edge * executing `say_hi' hihihi, var_deploy_type: 444
转载地址:http://twuci.baihongyu.com/