Exemple #1
0
    def set_logger(self):
        self.logFilePath = 'Log'
        self.logFileSize = 1000000
        self.logFileCount = 10

        if (self.conf_parser != None):
            if self.conf_parser.get('Log', 'LogFilePath') != '':
                self.logFilePath = self.conf_parser.get('Log', 'LogFilePath')

            self.logFileSize = self.conf_parser.get('Log', 'LogFileSize')
            self.logFileCount = self.conf_parser.get('Log', 'LogFileCount')

            if not os.path.exists(self.logFilePath):
                print self.logFilePath
                os.makedirs(self.logFilePath)

            LOG_NAME = '%s/%s_%s.log' % (self.logFilePath,
                                         os.path.basename(self.module)[:-3],
                                         self.section)
            Log.Init(Log.CRotatingLog(os.path.expanduser(LOG_NAME),
                                      int(self.logFileSize),
                                      int(self.logFileCount)))
Exemple #2
0
def main():
    module = os.path.basename(sys.argv[0])

    section = 'IRIS_MIGRATION'
    cfgfile = '/home/tacs/user/KimJW/Migration/migration.conf'

    cfg = ConfigParser.ConfigParser()
    cfg.read(cfgfile)

    log_file = '%s_%s.log' % (module, section)
    Log.Init(Log.CRotatingLog(log_file, 1000000, 9))

    im = IrisMirgration(cfg, section)
    loadTable = None

    if len(sys.argv) > 1:
        loadTable = sys.argv[1]
        im.loadData(loadTable)
    else:
        im.run()

    __LOG__.Trace('end main!')
Exemple #3
0
def main():
    module = os.path.basename(sys.argv[0])
    section = sys.argv[1]  # TACS_DB_LOADER
    cfgFile = sys.argv[2]

    cfg = ConfigParser.ConfigParser()
    cfg.read(cfgFile)

    logPath = cfg.get("GENERAL", "LOG_PATH")
    logFile = os.path.join(logPath, "%s_%s.log" % (module, section))

    logCfgPath = cfg.get("GENERAL", "LOG_CONF")

    logCfg = ConfigParser.ConfigParser()
    logCfg.read(logCfgPath)

    Log.Init(
        Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"),
                         logCfg.get("LOG", "MAX_CNT")))

    dl = DBLoader(section, cfg)
    dl.run()
Exemple #4
0
    def SetLog(self):
        #default Log
        self.logFilePath = 'Log'
        self.logFileSize = 1000000
        self.logFileCount = 10

        if (self.PARSER != None):
            if self.PARSER.get('Log', 'LogFilePath') != '':
                self.logFilePath = self.PARSER.get('Log', 'LogFilePath')

            self.logFileSize = self.PARSER.get('Log', 'LogFileSize')
            self.logFileCount = self.PARSER.get('Log', 'LogFileCount')

            if not os.path.exists(self.logFilePath):
                os.makedirs(self.logFilePath)

            LOG_NAME = '%s/%s_%s.log' % (self.logFilePath,
                                         os.path.basename(
                                             sys.argv[0])[:-3], self.SECTION)
            Log.Init(
                Log.CRotatingLog(os.path.expanduser(LOG_NAME),
                                 int(self.logFileSize),
                                 int(self.logFileCount)))
Exemple #5
0
def main():
    module = os.path.basename(sys.argv[0])
    section = sys.argv[1]  # TACS_FILE_MONITOR
    cfgfile = sys.argv[2]  # /home/tacs/user/KimJW/ETL/conf/FileMonitor.conf
    cfg = ConfigParser.ConfigParser()
    cfg.read(cfgfile)

    logPath = cfg.get("GENERAL", "LOG_PATH")
    logFile = os.path.join(logPath, "%s_%s.log" % (module, section))

    logCfgPath = cfg.get("GENERAL", "LOG_CONF")

    logCfg = ConfigParser.ConfigParser()
    logCfg.read(logCfgPath)

    Log.Init(
        Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"),
                         logCfg.get("LOG", "MAX_CNT")))

    fm = QMigration(cfg, section)
    fm.run(section)

    __LOG__.Trace("end main!")
Exemple #6
0
def main():
	global roleManager
	module = os.path.basename(sys.argv[0])

	section = sys.argv[1] # ROLE_MANAGER 
	cfgfile = sys.argv[2] # /home/tacs/TACS-EF/ETL/conf/RoleManager.conf

	try :
		cfg = ConfigParser.ConfigParser()
		cfg.read(cfgfile)

		if '-d' not in sys.argv :
			log_path = cfg.get('GENERAL', 'LOG_PATH')
			log_file = os.path.join(log_path, '%s_%s.log' % (module, section))
			Log.Init(Log.CRotatingLog(log_file, 10000000, 9))
		else:
			LOG.Init()
		roleManager = RoleManager(cfg, section)
		roleManager.run(section)
	except :
		__LOG__.Exception()

	__LOG__.Trace('end main!')
def main():
	print '111'
	module 	= os.path.basename(sys.argv[0])
	section = sys.argv[1] # MQConnect
	cfgfile = sys.argv[2] 

	cfg = ConfigParser.ConfigParser()
	cfg.read(cfgfile)

	logPath = cfg.get("GENERAL", "LOG_PATH")
	logFile = os.path.join(logPath, "%s_%s.log" % (module, section))

	logCfgPath = cfg.get("GENERAL", "LOG_CONF")

	logCfg = ConfigParser.ConfigParser()
	logCfg.read(logCfgPath)
	Log.Init(Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"), logCfg.get("LOG", "MAX_CNT") ))

	mc = MQConnect(cfg, section)
	print '222'
	mc.run()

	__LOG__.Trace("end main!")
Exemple #8
0
def main():
    cfg = ConfigParser.ConfigParser()
    cfg.read(sys.argv[2])
    log_dir = cfg.get("GENERAL", "LOG_DIR")
    log_name= os.path.join(log_dir, str(os.path.basename(sys.argv[0]))) + \
              "_" + \
              sys.argv[1] + ".log"
    Log.Init(Log.CRotatingLog(log_name, 1000000, 9))
    __LOG__.Trace(
        "=============================================================")
    __LOG__.Trace("      Module start")
    __LOG__.Trace(
        "=============================================================")

    time_list = config(cfg)
    scheduler(time_list)

    while True:
        try:
            time.sleep(1)
        except:
            __LOG__.Exception()
            break
Exemple #9
0
def main():
    module = os.path.basename(sys.argv[0])
    cfgfile = sys.argv[1]

    cfg = ConfigParser.ConfigParser()
    cfg.read(cfgfile)

    logPath = cfg.get("GENERAL", "LOG_PATH")
    logFile = os.path.join(logPath, "%s.log" % module)

    logCfgPath = cfg.get("GENERAL", "LOG_CONF")

    logCfg = ConfigParser.ConfigParser()
    logCfg.read(logCfgPath)

    Log.Init(
        Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"),
                         logCfg.get("LOG", "MAX_CNT")))

    workInfoFailOver = WorkInfoFailOver(cfg)
    workInfoFailOver.run()

    __LOG__.Trace('main is terminated')
Exemple #10
0
def main():
	global roleManager
	module = os.path.basename(sys.argv[0])

	section = sys.argv[1] # ROLE_MANAGER 
	cfgfile = sys.argv[2] # /home/tacs/TACS-EF/ETL/conf/RoleManager.conf

	cfg = ConfigParser.ConfigParser()
	cfg.read(cfgfile)

	logPath = cfg.get("GENERAL", "LOG_PATH")
	logFile = os.path.join(logPath, "%s_%s.log" % (module, section))

	logCfgPath = cfg.get("GENERAL", "LOG_CONF")

	logCfg = ConfigParser.ConfigParser()
	logCfg.read(logCfgPath)

	Log.Init(Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"), logCfg.get("LOG", "MAX_CNT") ))

	roleManager = RoleManager(cfg, section)
	roleManager.run(section)

	__LOG__.Trace('end main!')
Exemple #11
0
def main():
	module = os.path.basename(sys.argv[0])

	if len(sys.argv) > 2 : 
		section 	= sys.argv[1] # LOG_LOADER
		cfgfile 	= sys.argv[2] # /home/tacs/TACS-EF/LOG-ETL/conf/LOG-ETL.conf
		cfg 		= ConfigParser.ConfigParser()
		cfg.read(cfgfile)

		logPath = cfg.get("GENERAL", "LOG_PATH")
		logFile = os.path.join(logPath, "%s_%s.log" % (module, section))

		logCfgPath = cfg.get("GENERAL", "LOG_CONF")

		logCfg = ConfigParser.ConfigParser()
		logCfg.read(logCfgPath)

		Log.Init(Log.CRotatingLog(logFile, logCfg.get("LOG", "MAX_SIZE"), logCfg.get("LOG", "MAX_CNT") ))

		logLoader 	= LogLoader(cfg, section)
		logLoader.run()

	else : 
		__LOG__.Trace('Argument Length !!!')
Exemple #12
0
        sys.exit()

    loop(pars(ixml), idir)

    __LOG__.Trace("stop process")


def print_usage():
    print >> sys.stderr, "Usage : %s SUMMARY_NAME XML_FILE OUTPUT_DIR" % module
    print >> sys.stderr, "Exam  : %s CDR_SUMMARY_5M ~/SFMILOG/conf/IRIS_XML/CDR_SUMMARY.xml /DATA1/DEV/OUTPUT" % module


if __name__ == "__main__":
    module = os.path.basename(sys.argv[0])

    if len(sys.argv) < 4:
        print_usage()
        sys.exit()

    log_file = "log/%s_%s.log" % (os.path.basename(sys.argv[0]), sys.argv[1])
    if '-d' in sys.argv:
        Log.Init()
        sys.argv.remove('-d')
    else:
        Log.Init(Log.CRotatingLog(os.path.expanduser(log_file), 10000000, 19))

    try:
        main(sys.argv[2:])
    except:
        __LOG__.Exception()
Exemple #13
0
#!/home/mobigen/bin/python

import sys
import time
import getopt
import Mobigen.Common.Log as Log; 

OUTPUT = None
bNewLine = False

try: opts, args = getopt.getopt(sys.argv[1:], "no:", ["newline", "output="])
except getopt.GetoptError: sys.exit()

if(len(args)==3) :
	Log.Init(Log.CRotatingLog(args[0], args[1], args[2]))
else :
	Log.Init()

for o, v in opts:
	if o in ("-o", "--output"):
		exec("OUTPUT = __LOG__.%s" % (v))

	if o in ("-n", "--newline"):
		bNewLine = True

while True :
	if(bNewLine) :
		line = sys.stdin.readline()
	else :
		line = sys.stdin.readline().strip()
Exemple #14
0
		strLevel 		= 'ERROR'

	try :
		if opts.has_key( '--output-file' ) :
			fileName 	= opts['--output-file'].strip()		
			g_OUT_FILE	= open( fileName , 'w')

			#logfile = open('.\wa_bus.log', 'w')

	except :
		print "ERROR : Check output-file=: ", fileName, sys.exc_info()
		time.sleep(10)
		sys.exit()

	LOG_FILE = '%s.log' % sys.argv[0]
	Log.Init( Log.CRotatingLog( LOG_FILE, 10000000, 5, 'a+', g_DEBUG_LEVEL ) )
	__LOG__.Trace( "START :LEVEL [%s:%d], KEY:[%s]+++++++++++++++++++++++++++++++++++++++++++++++++" % (strLevel,g_DEBUG_LEVEL, g_INIT_KEY),  (logging.CRITICAL) )


	""" - TEST
	print "#########################################################"
	impStepList = extract_stack()
	impStepList.reverse()
	
	for impStep in impStepList:
		print "@@@@@@ ", impStep

	if(len(impStepList)!=1 ) :
		try : 
			parentModulePath = impStepList[0][0]
Exemple #15
0
    if len(sys.argv) > 2:
        SERVER_PORT = int(sys.argv[2])
        MDIR = MDIR + "_" + str(SERVER_PORT)

    if os.path.exists(MDIR) == False:
        try:
            os.mkdir(MDIR)
        except Exception, err:
            __LOG__.Exception(err)
            sys.exit()

    CONF_FILE = sys.argv[1]

    if os.path.exists(CONF_FILE) == False:
        print 'Error : %s not exists' % CONF_FILE
        sys.exit()

    conf = ConfigParser.ConfigParser()
    conf.read(CONF_FILE)

    if conf.has_section("CONF") and conf.has_option("CONF", "LOGFILE"):
        fileName = conf.get("CONF", "LOGFILE")
        Log.Init(Log.CRotatingLog(fileName, 10000000, 3))
    else:
        Log.Init(Log.CStandardErrorLog())

    try:
        main()
    except:
        __LOG__.Exception()
def main():
    global SHUTDOWN

    try:
        ### 뒤에 인수가 올경우 : 붙이고, 아닐경우 안붙인다
        ### : 에 상관없이 optList 는 튜플의 리스트로 반환된다.
        # optList, args = getopt.getopt(sys.argv[1:], 'p:f:t:w:n:i:')

        optList, args = getopt.getopt(sys.argv[1:], 'p:m:l:')
        if len(args) != 2: raise Exception
        optDict = {}
        for optKey, optVal in optList:
            optDict[optKey] = optVal

    except:
        #print 'usage : %s [-pftwni] homeDir infoFileName' % (sys.argv[0])
        #print '        -p[11] : protocol type, default:1'
        #print '        -f[okd|kd|d] : okd : message format = option(16byte) key(10byte) data'
        #print '                        kd : message format = key(10byte) data'
        #print '                         d : message format = data'
        #print '                           : default format = fileTime(yyyymmddhhmmss) option(16byte) key(10byte) data'
        #print '        -t[Num] : read block timeout second, default is 1, for signal process'
        #print '        -w[Num] : if no date to read, wait this second, default is 0.1'
        #print '        -n[Num] : if no data to read, list up next file for this second interval, default is 10'
        #print '        -i[Num] : info file update period record count, default is 10'
        #sys.exit()

        print 'VERSION: ' + VERSION
        print 'usage : %s [-p] serviceIP servicePort' % (sys.argv[0])
        print '        -p[1] : protocol type, default:6'
        print '        -l /home/eva/log/dict.log : logfile full path '
        print '        -m[bufsize] : socket read buffer size, only use in pType >= 6, default = 0'
        sys.exit()

    ### Env ###
    dict = {}
    servIP = args[0]
    servPort = int(args[1])
    qryCnt = 0
    logPrnCnt = 0

    defaultPType = 6
    if '-p' in optDict: defaultPType = int(optDict['-p'])
    if '-l' in optDict:
        Log.Init(Log.CRotatingLog(optDict['-l'], 10000000, 2))

    makeFileBufSize = 0
    if '-m' in optDict: makeFileBufSize = int(optDict['-m'])

    ### Socket Create ###
    server = mkServer(servIP, servPort)
    sockList = [server]
    childPType = {}
    childAddr = {}
    childSockFD = {}

    global SHUTDOWN
    global DEBUG

    while SHUTDOWN == False:
        try:
            inputReady, outputReady, exceptReady = select.select(
                sockList, [], [], 1)
        except Exception, err:
            __LOG__.Exception()
            break

        if len(inputReady) == 0:
            logPrnCnt += 1
            if logPrnCnt % 10 == 0:
                __LOG__.Trace("[%s:%s] ready, connections=[%s], qryCnt=[%s]" %
                              (servIP, servPort, len(sockList), qryCnt))
            continue

        for sock in inputReady:
            qryCnt += 1
            if qryCnt % 10000 == 0:
                __LOG__.Trace("[%s:%s] ready, connections=[%s], qryCnt=[%s]" %
                              (servIP, servPort, len(sockList), qryCnt))

            if sock == server:
                childSock, addr = server.accept()
                childSock.settimeout(1)  # no use for select
                sockList.append(childSock)

                addr = str(addr)
                childAddr[childSock] = addr
                childPType[childSock] = defaultPType
                childSockFD[childSock] = childSock.makefile(
                    bufsize=makeFileBufSize)
                __LOG__.Trace('Connected : %s' % addr)

            else:
                try:
                    res = False
                    try:
                        res = actClient(sock, childSockFD[sock], dict,
                                        childAddr[sock], childPType)
                    except:
                        res = False
                    if res == False:
                        sockList.remove(sock)
                        sock.close()
                        __LOG__.Trace('Removed : %s ' % childAddr[sock])
                        del (childPType[sock])
                        del (childAddr[sock])
                        del (childSockFD[sock])

                    elif type(res) == int:
                        server.close()
                        sockList.remove(server)

                        server = mkServer(servIP, res)
                        sockList.append(server)
                        servPort = res

                except Exception, err:
                    __LOG__.Exception()
                    continue
Exemple #17
0

def main():
    if len(sys.argv) < 2 or len(sys.argv) > 3:
        print("usage: %s confFileName [clear]" % sys.argv[0])
        sys.exit()

    ### Make Config ###
    logPrn("--------------------------------------------")
    logPrn(" START !!!!!!")
    confFileName = sys.argv[1]
    ef = SIOEventFlow(confFileName)
    errPrn(">>> main : debug 1 : ")
    ef.run()


if __name__ == "__main__":
    import Mobigen.Common.Log as Log
    import sys, os, getopt
    OPT, ARGS = getopt.getopt(sys.argv[1:], 'd')
    LOG_NAME = '~/LOG/%s.log' % (os.path.basename(sys.argv[0]))

    try:
        OPT.index(('-d', ''))
        Log.Init()
    except:
        Log.Init(Log.CRotatingLog(os.path.expanduser(LOG_NAME), 1000000, 5))
    sys.argv = [sys.argv[0]] + ARGS

    main()
Exemple #18
0
 def SetLog(self):
     Log_file = os.path.join(self.LOG_PATH, "%s.log" % sys.argv[5])
     Log.Init(
         Log.CRotatingLog(os.path.expanduser(Log_file), self.LOG_SIZE,
                          self.LOG_COUNT))
Exemple #19
0
def main() :

	global g_sequence, g_sequence_timeout, g_wait_time, g_isFile

	if len(sys.argv) < 3 :
		usage()
		sys.exit()

	try:
		opts, args = getopt.getopt(sys.argv[1:], "hsw:ct:fn:", ["help", "waittime"])
	except :
		# print help information and exit:
		usage()
		sys.exit(2)

	iniFile = False

	g_wait_time = 0
	
	logSize = 10000000
	logFileNum = 3
	for o, a in opts:
		if o in ("-h", "--help"):
			usage()
			sys.exit()
		if o in ("-s"):
			g_sequence = True
		if o in ("-w", "--waittime"):
			g_sequence_timeout = int(a)
		if o in ("-c"):
			iniFile = True
		if o in ("-t"):
			g_wait_time = int(a)
		if o in ("-f"):
			g_isFile = True
		if o in ("-n"):
			try:
				(logFileNum, logSize) = map(int, a.split(","))
			except:
				logSize = 10000000
				logFileNum = 3

	if iniFile == False and  len(args) < 2:
		usage()
		sys.exit()

	log_port = None

	if iniFile :
		iniFileName = args.pop()
		(args, log_port) = readIniFile(iniFileName, args)
	else :
		log_port = args.pop()


	if not log_port:
		__LOG__.Trace( "log_port error" )
		usage()
		sys.exit()


	if g_isFile:
		# -f 옵션인 경우 파일에 저장함.
		Log.Init( Log.CRotatingLog( log_port, logSize, logFileNum ) )
	

	__LOG__.Trace( "log_port: [%s]" % log_port)

	
	countProcess = SFLauncher(args, log_port)
	countProcess.setDaemon(True)
	countProcess.start()

	global SHUTDOWN

	while 1 :
		try:
			if SHUTDOWN : break
			#else : time.sleep(1)
			else : select.select([],[],[], 1)
		except:
			if SHUTDOWN : break
			pass

	__LOG__.Trace('MAIN : kill()')
	countProcess.kill()
	countProcess.join()

	__LOG__.Trace('MAIN : closed')
Exemple #20
0
    def __init__(self, section, conf_path, options, args):
        self.options = options
        self.args = args
        self.starttime = 0
        self.endtime = 0
        self.port = 22
        self.sleep_time = 5
        self.local_dir = os.getcwd()
        self.index_path = os.getcwd()
        self.index_name = sys.argv[0] + '_' + section
        self.optionparsing()

        try:
            #Config 파일 불러들임.
            self.config = ConfigParser.ConfigParser()
            self.config.read(conf_path)

            #log설정
            module = os.path.basename(sys.argv[0])
            logpath = self.config.get('Log', 'LOG_PATH')
            logsize = self.config.get('Log', 'LOG_SIZE')
            logcount = self.config.get('Log', 'LOG_COUNT')
            logname = os.path.expanduser('%s/%s_%s.log' %
                                         (logpath, module, section))
            Log.Init(Log.CRotatingLog(logname, logsize, logcount))
        except:
            __LOG__.Exception()
            os._exit(1)

        try:
            #ssh connection
            self.ip = self.config.get(section, 'ftp_ip')
            self.remote_host = self.config.get(section, 'ftp_id')
            self.remote_password1 = self.config.get(section, 'ftp_pwd1')
            self.remote_password2 = self.config.get(section, 'ftp_pwd2')
            self.remote_dir = self.config.get(section, 'REMOTE_DIR')
            self.remote_patt = self.config.get(section, 'REMOTE_PATT')
            self.pathsidx = self.config.getint(
                section, 'PATHSIDX'
            )  #로컬의 저장하고자 하는 파일위치를 원격지의 패스에서 일부 가져다 씀 시작(basename 제외)
            self.patheidx = self.config.getint(
                section, 'PATHEIDX')  #로컬의 저장하고자 하는 파일위치를 원격지의 패스에서 일부 가져다 씀 끝
        except:
            __LOG__.Exception()
            os._exit(1)

        if self.config.has_option(section, 'ftp_port'):
            self.port = self.config.getint(section, 'ftp_port')
        if self.config.has_option(section, 'SLEEP_TIME'):
            self.sleep_time = self.config.getint(section, 'SLEEP_TIME')
        if self.config.has_option(section, 'LOCAL_DIR'):
            self.local_dir = self.config.get(section, 'LOCAL_DIR')
        if self.config.has_option(section, 'INDEX_PATH'):
            self.index_path = self.config.get(section, 'INDEX_PATH')
        if self.config.has_option(section, 'INDEX_NAME'):
            self.index_name = self.config.get(section, 'INDEX_NAME')

        if not os.path.exists(self.local_dir):
            os.makedirs(self.local_dir)
        if not os.path.exists(self.index_path):
            os.makedirs(self.index_path)

        self.RUN_TIME = dt.datetime.now()
        self.run()
Exemple #21
0
    # SendMessage Timeout
    #-------------------------------------------------------
    try:
        if opts.has_key('-t'):
            g_SEND_TIMEOUT = int(opts['-t'].strip())
    except:
        pass  # default timeout

    #-------------------------------------------------------
    # if SendMessage Timeout Failed, retry Falg : 07.09.28
    #-------------------------------------------------------
    try:
        if opts.has_key('-r'):
            g_RETRY_SENDFLAG = True
    except:
        pass  # default timeout

    #-------------------------------------------------------
    # HeartBeat, Key
    #-------------------------------------------------------
    g_INIT_KEY = '0,*,*'  # heartbeat,key1,key2
    g_INIT_KEY = args[2]

    LOG_FILE = '%s.log' % sys.argv[0]
    Log.Init(Log.CRotatingLog(LOG_FILE, 10000000, 3, 'a', debugLevel))
    __LOG__.Trace(
        "START :LEVEL [%s:%d], KEY:[%s]+++++++++++++++++++++++++++++++++++++++++++++++++"
        % (strLevel, debugLevel, g_INIT_KEY), (logging.CRITICAL))

    main()
Exemple #22
0
def main():
    global SHUTDOWN

    try:
        optStr = sfp.getOptStr()
        optStr += "f:"
        optList, args = getopt.getopt(sys.argv[1:], optStr, [
            "deny=",
        ])
        if len(args) != 2: raise Exception
        opts = {}
        for optKey, optVal in optList:
            opts[optKey] = optVal
    except:
        print 'VERSION: %s' % VERSION
        print 'usage : %s [-options] servIP servPort' % (sys.argv[0])
        sfp.prnOpt()
        print "        -f[logfilePath]  : logfilePath"
        print "        --deny=host.deny  : host deny ip"
        sys.exit()

    key1Hash = {}
    key2Hash = {}
    keyBothHash = {'*,*': []}

    if opts.has_key("-f"):
        # -f logfilePath
        fileName = opts["-f"]
        Log.Init(Log.CRotatingLog(fileName, 10000000, 3))
    else:
        # opts
        Log.Init(Log.CStandardErrorLog())

    pType = 1  # default protocol type 1
    if opts.has_key("-p"):
        try:
            pType = int(opts["-p"])
        except:
            pType = 1

    denyIpHash = {}
    if opts.has_key("--deny"):
        fileName = opts["--deny"]
        readDenyFile(fileName, denyIpHash)

    servIP = args[0]
    servPort = int(args[1])

    servsock = socket(AF_INET, SOCK_STREAM)
    servsock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    servsock.bind(('', int(servPort)))
    servsock.listen(10)

    #servsock.setblocking(False) # non block

    global inSockList, sockConnectorHash

    inSockList = [servsock]
    sockConnectorHash = {}
    conList = []

    __LOG__.Trace("[%s:%s] Start ---" % (servIP, servPort))

    startSec = time.time()
    qryCnt = 1
    while SHUTDOWN == False:
        try:  #{
            try:
                inputReady,outputReady,exceptReady = \
                 select.select(inSockList,[],[], 0.1)
            except Exception, err:
                __LOG__.Exception()
                raise sfp.SFPDiscon, err

            if len(inputReady) == 0:
                aliveSec = time.time() - startSec

                if aliveSec >= 60:
                    __LOG__.Trace( "[%s:%s] ready, conList=[%s], qryCnt=[%s]" \
                    % (servIP, servPort, len(conList), qryCnt) )
                    startSec = time.time()

                for th in conList:
                    if th.heartBeatSec != 0:
                        th.ansHeart()

            if qryCnt % 100 == 0:
                for th in conList:
                    if th.heartBeatSec != 0:
                        th.ansHeart()

                if qryCnt % 10000 == 0:
                    __LOG__.Trace( "[%s:%s] ready, conList=[%s], qryCnt=[%s]" \
                    % (servIP, servPort, len(conList), qryCnt) )

            idx = 0
            for sock in inputReady:  #{

                idx += 1
                __LOG__.Trace("inputReady, [%d/%d]" % (idx, len(inputReady)))

                qryCnt += 1

                if sock == servsock:
                    cSock, addr = servsock.accept()

                    # 접속 거부
                    if denyIpHash.has_key(addr[0]):
                        cSock.close()
                        __LOG__.Trace("deny ip [%s]" % addr[0])
                        continue

                    inSockList.append(cSock)

                    addr = str(addr)
                    connector = Connector(cSock, addr, key1Hash, key2Hash,
                                          keyBothHash, conList, **opts)
                    sockConnectorHash[cSock] = connector

                    __LOG__.Trace("connected, addr=%s" % addr)

                else:
                    connector = sockConnectorHash[sock]

                    try:  # try

                        idx = 0
                        readData(sock, key1Hash, key2Hash, keyBothHash)

                        while pType == 6:
                            if (not readData(sock, key1Hash, key2Hash,
                                             keyBothHash, True)):
                                __LOG__.Trace(
                                    "+++++ readData END TIMEOUT ++++++ %s,fd:[%d]"
                                    % (addr, sock.fileno()))
                                break

                            idx += 1

                            if idx >= 100:
                                __LOG__.Trace(
                                    "+++++ readData END 100 ++++++ %s,fd:[%d]"
                                    % (addr, sock.fileno()))

                                break

                    except Exception, err:

                        __LOG__.Exception()

                        try:
                            inSockList.remove(sock)
                        except:
                            pass

                        try:
                            del (sockConnectorHash[sock])
                        except:
                            pass

                        connector.deregister()
                        sock.close()

                        continue