from os.path import abspath, dirname, join, normpath PREFIX = normpath(dirname(abspath(__file__))) for path in (PREFIX, normpath(join(PREFIX, '../lib'))): if path not in sys.path: sys.path = [path] + sys.path SERVER_NAME = 'MESSAGESERVER' import config config.init(SERVER_NAME) import log log.init(config.log_threshold) import redis redis.init(config.redis_conf) ''' from syslogger import init_logger syslog_conf = config.syslog_conf.split(',') if len(syslog_conf) > 1: syslog_conf = (syslog_conf[0], int(syslog_conf[1])) else: syslog_conf = syslog_conf[0] init_logger( syslog_conf ) ''' from server import Server from datetime import datetime server = Server()
from os.path import abspath, dirname, join, normpath PREFIX = normpath(dirname(abspath(__file__))) for path in (PREFIX, normpath(join(PREFIX, '../lib'))): if path not in sys.path: sys.path = [path] + sys.path SERVER_NAME = 'MESSAGESERVER' import config config.init(SERVER_NAME) import log log.init(config.log_threshold) import redis redis.init(config.redis_conf) ''' from syslogger import init_logger syslog_conf = config.syslog_conf.split(',') if len(syslog_conf) > 1: syslog_conf = (syslog_conf[0], int(syslog_conf[1])) else: syslog_conf = syslog_conf[0] init_logger( syslog_conf ) ''' from server import Server from datetime import datetime
reload(sys) sys.setdefaultencoding('utf-8') from os.path import abspath, dirname, join, normpath PREFIX = normpath(dirname(abspath(__file__))) for path in (PREFIX, normpath(join(PREFIX, '../lib'))): if path not in sys.path: sys.path = [path] + sys.path import setting SERVER_NAME = 'GAMESERVER' import log log.init(setting.LOG_THRESHOLD) import redis redis.init(setting.REDIS_CONF) from server import Server from datetime import datetime server = Server() reactor.addSystemEventTrigger('before', 'shutdown', server.cleanup) application = service.Application(SERVER_NAME) logfile = LogFile('game.log', join(PREFIX, '../logs'), rotateLength=setting.LOG_ROTATE_INTERVAL) logOb = FileLogObserver(logfile) logOb.formatTime = lambda when : datetime.fromtimestamp(when).strftime('%m/%d %T.%f') application.setComponent( ILogObserver, logOb.emit ) internet.TCPServer(setting.GAMESERVER['port'], server, interface=setting.GAMESERVER['hostname']).setServiceParent(service.IServiceCollection(application)) internet.TCPServer(setting.GAMESERVER['adminport'], ShellFactory(), interface=setting.GAMESERVER['hostname']).setServiceParent(service.IServiceCollection(application))