Last active
December 28, 2015 20:38
-
-
Save hagiyat/7558331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# python 2.7.5 / fabric 1.7.0 | |
from fabric.api import env, run | |
from fabric.decorators import roles, task | |
from fabric.decorators import parallel | |
env.use_ssh_config = True | |
env.colorize_errors = True | |
env.warn_only = True | |
# 接続したいサーバーの定義 | |
env.roledefs.update({ | |
"production-srv": ["prod-srv%02d" % idx for idx in range(1, 12)], | |
"staging-srv": ["staging-srv%s" % chr(idx) for idx in range(ord('a'), ord('e'))], | |
"test-srv": ["test-srv%02d" % idx for idx in range(1, 2)] | |
}) | |
# ファイルのパスとgrepの検索ワード指定 | |
# $ fab -R [role] tailf:"/path/to/logfile", "grep-word" | |
@task | |
@parallel | |
def tailf(path="/path/to/logfile", grep=""): | |
try: | |
cmd = "tail -F %s" % path | |
if (grep): | |
cmd += " | grep %s" % grep | |
run(cmd) | |
except (KeyboardInterrupt, SystemExit): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment