Ejemplo n.º 1
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """

        servername = config.get('name')  #服务器名称
        logpath = config.get('log')  #日志
        hasdb = config.get('db')  #数据库连接
        hasmem = config.get('mem')  #memcached连接

        app = config.get('app')  #入口模块名称

        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            self.leafNode = leafNode(servername)
            self.leafNode.connect(addr)
            GlobalObject().leafNode = self.leafNode

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))  #日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)
Ejemplo n.º 2
0
    def config(self,config,dbconfig = None,memconfig = None,masterconf=None):
        """配置服务器
        """
        remoteportlist = config.get('remoteport',[])#remote节点配置列表
        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        hasdb = config.get('db')#数据库连接
        hasmem = config.get('mem')#memcached连接
        app = config.get('app')#入口模块名称
        mreload = config.get('reload')#重新加载模块名称
        self.servername = servername


        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())

            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode


        for cnf in remoteportlist:
            rname = cnf.get('rootname')
            rport = cnf.get('rootport')
            self.remote[rname] = leafNode(servername)
            addr = ('localhost',rport)
            self.remote[rname].connect(addr)

        GlobalObject().remote = self.remote

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))#日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)

        if mreload:
            GlobalObject().reloadmodule = __import__(mreload)
Ejemplo n.º 3
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """
        rootport = config.get('rootport')#root节点配置
        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        hasdb = config.get('db')#数据库连接
        hasmem = config.get('mem')#memcached连接
        app = config.get('app')#入口模块名称
        self.servername = servername


        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode


        if rootport:
            self.root = PBRoot("rootservice")
            reactor.listenTCP(rootport, BilateralFactory(self.root))
            GlobalObject().root = self.root

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))#日志处理
        log.startLogging(sys.stdout)


        if app:
            reactor.callLater(0.1,__import__,app)
Ejemplo n.º 4
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """
        rootport = config.get('rootport')  #root节点配置
        servername = config.get('name')  #服务器名称
        logpath = config.get('log')  #日志
        hasdb = config.get('db')  #数据库连接
        hasmem = config.get('mem')  #memcached连接
        app = config.get('app')  #入口模块名称
        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode

        if rootport:
            self.root = PBRoot("rootservice")
            reactor.listenTCP(rootport, BilateralFactory(self.root))
            GlobalObject().root = self.root

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))  #日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)
Ejemplo n.º 5
0
    def config(self,config,dbconfig = None,memconfig = None,masterconf=None):
        """配置服务器
        """

        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        hasdb = config.get('db')#数据库连接
        hasmem = config.get('mem')#memcached连接

        app = config.get('app')#入口模块名称

        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            self.leafNode = leafNode(servername)
            self.leafNode.connect(addr)
            GlobalObject().leafNode = self.leafNode


        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))#日志处理
        log.startLogging(sys.stdout)


        if app:
            reactor.callLater(0.1,__import__,app)
Ejemplo n.º 6
0
 from dbpool import dbpool
 from memclient import memcached_connect
 from madminanager import MAdminManager
 memcached_connect(["127.0.0.1:11211"])
 aa = {"default":{'host':"localhost",'user':'******',
     'passwd':'111',
     'db':'legend',
     'port':3306,
     'charset':'utf8'},
   "master":{'host':"localhost",'user':'******',
     'passwd':'111',
     'db':'test',
     'port':3306,
     'charset':'utf8'}
   }
 dbpool.initPool(aa)
 
 class router: 
     def db_for_read(self, **kw):
         return "master"
     def db_for_write(self, **kw):
         return "master"
 
 dbpool.bind_router(router)
 
 ma = MAdmin('tb_role_info','id',incrkey='id',fk="username")
 mm = ma.getObj(19)
 mm.update("username", "llllll")
 print ma.getAllPkByFk('lanjinmin')
 MAdminManager().checkAdmins()
 
Ejemplo n.º 7
0
            'user': '******',
            'passwd': '111',
            'db': 'legend',
            'port': 3306,
            'charset': 'utf8'
        },
        "master": {
            'host': "localhost",
            'user': '******',
            'passwd': '111',
            'db': 'test',
            'port': 3306,
            'charset': 'utf8'
        }
    }
    dbpool.initPool(aa)

    class router:
        def db_for_read(self, **kw):
            return "master"

        def db_for_write(self, **kw):
            return "master"

    dbpool.bind_router(router)

    ma = MAdmin('tb_role_info', 'id', incrkey='id', fk="username")
    mm = ma.getObj(19)
    mm.update("username", "llllll")
    print ma.getAllPkByFk('lanjinmin')
    MAdminManager().checkAdmins()
Ejemplo n.º 8
0
	cursor.close()
	conn.close()
	if(count >= 1):
		return True
	return False

if __name__ == '__main__':
	import json

	sqlcfg = {'host':"127.0.0.1",
	'user':'******',
	'passwd':'112233',
	'db':'gamedb',
	'port':3306,
	'charset':'utf8'}
	dbpool.initPool(**sqlcfg)


	print FormatCondition({'id' : 1})

	import time
	t = time.time()
	for i in range(1):
		GetAllRecordInfo('sys_config', {'id': 1})
	print time.time() - t


	
	buildinglevelcfg = {
		1: {
			0: {'timeinterval': 0, 'generate': 0, 'upgrade': 100, 'timedisabled': 600},