1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-07 15:06:47 +00:00

link fail log

这个提交包含在:
bigeagle
2014-11-21 18:47:36 +08:00
父节点 e278f7901f
当前提交 5f8e113364

查看文件

@@ -21,6 +21,7 @@ class LogLimitHook(JobHook):
return return
log_link = os.path.join(log_dir, "latest") log_link = os.path.join(log_dir, "latest")
ctx['log_link'] = log_link
lfiles = [os.path.join(log_dir, lfile) lfiles = [os.path.join(log_dir, lfile)
for lfile in os.listdir(log_dir) for lfile in os.listdir(log_dir)
@@ -42,7 +43,31 @@ class LogLimitHook(JobHook):
pass pass
# create a soft link # create a soft link
if log_link != log_file: self.create_link(log_link, log_file)
def after_job(self, status=None, ctx={}, *args, **kwargs):
log_file = ctx.get('log_file', None)
log_link = ctx.get('log_link', None)
if log_file == "/dev/null":
return
if status == "fail":
log_file_save = log_file + ".fail"
try:
sh.mv(log_file, log_file_save)
except:
pass
self.create_lin(log_link, log_file_save)
def ensure_log_dir(self, log_dir):
if not os.path.exists(log_dir):
sh.mkdir("-p", log_dir)
def create_link(self, log_link, log_file):
if log_link == log_file:
return
if not (log_link and log_file):
return
if os.path.lexists(log_link): if os.path.lexists(log_link):
try: try:
sh.rm(log_link) sh.rm(log_link)
@@ -53,19 +78,5 @@ class LogLimitHook(JobHook):
except: except:
return return
def after_job(self, status=None, ctx={}, *args, **kwargs):
log_file = ctx.get('log_file', None)
if log_file == "/dev/null":
return
if status == "fail":
log_file_save = log_file + ".fail"
try:
sh.mv(log_file, log_file_save)
except:
pass
def ensure_log_dir(self, log_dir):
if not os.path.exists(log_dir):
sh.mkdir("-p", log_dir)
# vim: ts=4 sw=4 sts=4 expandtab # vim: ts=4 sw=4 sts=4 expandtab