예제 #1
0
파일: master.py 프로젝트: wizcas/G-Firefly
 def start(self):
     '''
     '''
     sys_args = sys.argv
     if len(sys_args)>2 and sys_args[1] == "single":
         server_name = sys_args[2]
         if server_name == "master":
             mode = MASTER_SERVER_MODE
         else:
             mode = SINGLE_SERVER_MODE
     else:
         mode = MULTI_SERVER_MODE
         server_name = ""
         
     if mode == MULTI_SERVER_MODE:
         self.masterapp()
         config = self.__loadconfig()
         sersconf = config.get('servers')
         for sername in sersconf.keys():
             cmds = 'python %s %s %s'%(self.mainpath,sername,self.configpath)
             subprocess.Popen(cmds,shell=True)
         reactor.run()
     elif mode == SINGLE_SERVER_MODE:
         config = self.__loadconfig()
         sername = server_name
         cmds = 'python %s %s %s'%(self.mainpath,sername,self.configpath)
         subprocess.Popen(cmds,shell=True)
     else:
         self.masterapp()
         reactor.run()
예제 #2
0
    def start(self):
        '''
        '''
        sys_args = sys.argv
        if len(sys_args) > 2 and sys_args[1] == "single":
            server_name = sys_args[2]
            if server_name == "master":
                mode = MASTER_SERVER_MODE
            else:
                mode = SINGLE_SERVER_MODE
        else:
            mode = MULTI_SERVER_MODE
            server_name = ""

        if mode == MULTI_SERVER_MODE:
            self.masterapp()
            config = json.load(open(self.configpath, 'r'))
            sersconf = config.get('servers')
            for sername in sersconf.keys():
                cmds = 'python %s %s %s' % (self.mainpath, sername,
                                            self.configpath)
                subprocess.Popen(cmds, shell=True)
            reactor.run()
        elif mode == SINGLE_SERVER_MODE:
            config = json.load(open(self.configpath, 'r'))
            sername = server_name
            cmds = 'python %s %s %s' % (self.mainpath, sername,
                                        self.configpath)
            subprocess.Popen(cmds, shell=True)
        else:
            self.masterapp()
            reactor.run()
def serverstart():
    '''服务配置
    '''
    log.startLogging(sys.stdout)
    factory.addServiceChannel(service)
#     reactor.callLater(10,factory.pushObject,111,'asdfe',[0])
#     reactor.callLater(15,factory.loseConnection,0)
    reactor.listenTCP(1000,factory)
    reactor.run()
예제 #4
0
def serverstart():
    '''服务配置
    '''
    log.startLogging(sys.stdout)
    factory.addServiceChannel(service)
    reactor.callLater(10,factory.pushObject,111,'asdfe',[0])
    reactor.callLater(15,factory.loseConnection,0)
    reactor.listenTCP(1000,factory)
    reactor.run()
예제 #5
0
파일: master.py 프로젝트: Cuick/traversing
    def start(self):
        '''baidu
        '''
        sys_args = sys.argv
        if len(sys_args) > 2 and sys_args[1] == "single":
            server_name = sys_args[2]
            if server_name == "master":
                mode = MASTER_SERVER_MODE
            else:
                mode = SINGLE_SERVER_MODE
        else:
            mode = MULTI_SERVER_MODE
            server_name = ""

        if mode == MULTI_SERVER_MODE:
            self.masterapp()
            config = json.load(open(self.configpath, 'r'))
            sersconf = config.get('servers')
            for sername in sersconf.keys():
                # cmds = "kernprof -o app/logs/%s.lprof -l -b %s %s %s " % (sername, self.mainpath, sername, self.configpath)
                cmds = 'python %s %s %s' % (self.mainpath, sername,
                                            self.configpath)
                # cmds = 'python -m profile %s %s %s' % (self.mainpath, sername, self.configpath)
                # print 'mutiple', cmds
                subprocess.Popen(cmds, shell=True)
            reactor.run()
        elif mode == SINGLE_SERVER_MODE:
            self.masterapp()
            # config = json.load(open(self.configpath, 'r'))
            sername = server_name
            cmds = 'python %s %s %s' % (self.mainpath, sername,
                                        self.configpath)
            # print 'single', cmds
            subprocess.Popen(cmds, shell=True)
            reactor.run()
        else:
            self.masterapp()
            reactor.run()
예제 #6
0
    def start(self):
        '''baidu
        '''
        sys_args = sys.argv
        if len(sys_args) > 2 and sys_args[1] == "single":
            server_name = sys_args[2]
            if server_name == "master":
                mode = MASTER_SERVER_MODE
            else:
                mode = SINGLE_SERVER_MODE
        else:
            mode = MULTI_SERVER_MODE
            server_name = ""

        if mode == MULTI_SERVER_MODE:
            self.masterapp()
            config = json.load(open(self.configpath, 'r'))
            sersconf = config.get('servers')
            for sername in sersconf.keys():
                # cmds = "kernprof -o app/logs/%s.lprof -l -b %s %s %s " % (sername, self.mainpath, sername, self.configpath)
                cmds = 'python %s %s %s' % (self.mainpath, sername, self.configpath)
                # cmds = 'python -m profile %s %s %s' % (self.mainpath, sername, self.configpath)
                # print 'mutiple', cmds
                subprocess.Popen(cmds, shell=True)
            reactor.run()
        elif mode == SINGLE_SERVER_MODE:
            self.masterapp()
            # config = json.load(open(self.configpath, 'r'))
            sername = server_name
            cmds = 'python %s %s %s' % (self.mainpath, sername, self.configpath)
            # print 'single', cmds
            subprocess.Popen(cmds, shell=True)
            reactor.run()
        else:
            self.masterapp()
            reactor.run()
예제 #7
0
def startClient():
    reactor.callLater(3, apptest, 'printData1', u"node测试1", u"node测试2")
    reactor.callLater(5, apptest, 'printData1', u"node测试1", u"node测试2")
    remote.connect(addr)  #连接远程主机
    reactor.run()
예제 #8
0
log.startLogging(sys.stdout)
    
root = PBRoot()
ser = services.Service('test')
root.addServiceChannel(ser)


def serviceHandle(target):
    '''服务处理
    @param target: func Object
    '''
    ser.mapTarget(target)

@serviceHandle
def printData1(data,data1):
    print data,data1
    print "############################"
    d = root.callChild("test_node",1,u'Root测试')
    return data

@serviceHandle
def printData2(data,data1):
    print data,data1
    print "############################"
    d = root.callChild("test_node",1,u'Root测试')
    return data

if __name__=='__main__':
    reactor.listenTCP(9090, BilateralFactory(root))
    reactor.run()
예제 #9
0
 def start(self):
     '''启动服务器
     '''
     log.msg('[%s] started...' % self.servername)
     log.msg('[%s] pid: %s' % (self.servername, os.getpid()))
     reactor.run()
예제 #10
0
def startClient():
    reactor.callLater(3,apptest,'printData1',u"node测试1",u"node测试2")
    remote.connect(addr)#连接远程主机
    reactor.run()
예제 #11
0
ser = services.Service('test')
root.addServiceChannel(ser)


def serviceHandle(target):
    '''服务处理
    @param target: func Object
    '''
    ser.mapTarget(target)


@serviceHandle
def printData1(data, data1):
    print data, data1
    print "############################"
    d = root.callChild("test_node", 1, u'Root测试')
    return data


@serviceHandle
def printData2(data, data1):
    print data, data1
    print "############################"
    d = root.callChild("test_node", 1, u'Root测试')
    return data


if __name__ == '__main__':
    reactor.listenTCP(9090, BilateralFactory(root))
    reactor.run()
예제 #12
0
파일: server.py 프로젝트: 9miao/G-Firefly
 def start(self):
     '''启动服务器
     '''
     log.msg('[%s] started...'%self.servername)
     log.msg('[%s] pid: %s'%(self.servername,os.getpid()))
     reactor.run()
예제 #13
0
 def start(self):
     """启动服务器"""
     logger.info('%s start...', self.servername)
     logger.info('%s pid: %s' % (self.servername, os.getpid()))
     reactor.run()
예제 #14
0
 def start(self):
     """启动服务器"""
     logger.info('%s start...', self.servername)
     logger.info('%s pid: %s' % (self.servername, os.getpid()))
     reactor.run()