Esempio n. 1
0
                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()
Esempio n. 2
0
@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)