Example #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)
Example #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)
Example #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)
Example #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)
Example #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)