我们有一个在多个主机上并行运行的 Python 结构命令,如下所示:
$ fab --hosts=prod1.server,prod2.server,prod3.server --parallel copy_cache
Run Code Online (Sandbox Code Playgroud)
这会将缓存复制到并行列出的生产服务器。由于 XXgig 缓存目录可能需要数小时,因此在整个过程中会发生各种日志记录以指示我们的进展情况。由于复制是并发进行的,因此在命令行上运行时的输出会实时交错返回,如下所示:
[prod1.server] Executing task 'nginx_cache_copy'
[prod2.server] Executing task 'nginx_cache_copy'
[prod3.server] Executing task 'nginx_cache_copy'
2014-09-16 10:02:29.688243
[prod1.server] INFO: rsyncing cache dir
[prod1.server] run: rsync -a -q cache.server:"repo/cache/some.site.com" \
"repo/cache/."
2014-09-16 10:02:29.716345
[prod2.server] INFO: rsyncing cache dir
[prod2.server] run: rsync -a -q cache.server:"repo/cache/some.site.com" \
"repo/cache/."
2014-09-16 10:02:29.853275
[prod3.server] INFO: rsyncing cache dir
[prod3.server] run: rsync -a -q cache.server:"repo/cache/some.site.com" \
"repo/cache/."
2014-09-16 10:02:29.984154
[prod1.server] INFO: Reloading nginx config
[prod1.server] run: sbin/nginx -s reload …Run Code Online (Sandbox Code Playgroud)