self.meta.flush(self.meta_info) if old_pos + read_len == size: break else: continue else: break return pos def __move_file(self): last_file = self.q.pop(0) self.meta_info.cur_file = self.q[0] self.meta_info.offset = 0L self.offset = 0L toDel = self.scanner.addToDel(last_file) self.meta_info.last_file = ",".join(toDel) logger.error("CHECK_" + self.cp_name + ": remove file: " + self.meta_info.last_file + " and current file: " + self.meta_info.cur_file + " at offset: " + str(self.meta_info.offset)) if __name__ == '__main__': conf = Config("../../conf/tailfile.conf") tail = Tail(0, conf) tail.start() sleep(3) tail.join()
self.config.readfp(fd) except IOError: print 'read log conf error ' + str(traceback.format_exc()) sys.exit(1) finally: fd.close() def getLogPath(self): value = self.config.get('handler_fileHandler', 'args') if value is None or value is "": print "no log name defined in log conf" sys.exit(1) return eval(value)[0] basepath = os.path.dirname(__file__) log_config = LogConfig(basepath + "/../conf/log.conf") conf = Config(basepath + '/../conf/tailfile.conf') class HealthCheck(object): def __init__(self, log_path, cp_path, cpname): self.log_path = log_path self.dir = cp_path self.name = cpname pass def __check_meta(self): print "{COLLECT CHECK INFO BEGIN}" f = None while True: index = self.__max_index() if index == -1L: print "no meta found"
@author: jiugao ''' import logging from logging import config import os, sys from ptail.Config import Config from ptail.Tail import Tail import signal import traceback from time import sleep from client.TimeTunnel2 import use, passport, set_router, release basepath = os.path.dirname(__file__) config.fileConfig(basepath + "/../conf/log.conf") conf = Config(basepath + '/../conf/tailfile.conf') logger = logging.getLogger("tailfile") class SingleInstance: def __init__(self): self.lockfile = os.path.normpath(basepath + '/' + os.path.basename(__file__) + '.lock') if sys.platform == 'win32': try: # file already exists, we try to remove (in case previous execution was interrupted) if (os.path.exists(self.lockfile)): os.unlink(self.lockfile) self.fd = os.open(self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR)
@author: jiugao ''' import logging from logging import config import os, sys from ptail.Config import Config from ptail.Tail import Tail import signal import traceback from time import sleep from client.TimeTunnel2 import use, passport, set_router, release basepath = os.path.dirname(__file__) config.fileConfig(basepath + "/../conf/log.conf") conf = Config(basepath + '/../conf/tailfile.conf') logger = logging.getLogger("tailfile") class SingleInstance: def __init__(self): self.lockfile = os.path.normpath(basepath + '/' + os.path.basename(__file__) + '.lock') if sys.platform == 'win32': try: # file already exists, we try to remove (in case previous execution was interrupted) if(os.path.exists(self.lockfile)): os.unlink(self.lockfile) self.fd = os.open(self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR) except OSError, e: if e.errno == 13: