Ejemplo n.º 1
0
 def masterapp(self):
     """
     """
     config = json.load(open(self.configpath, 'r'))
     GlobalObject().json_config = config
     mastercnf = config.get('master')
     rootport = mastercnf.get('rootport')
     webport = mastercnf.get('webport')
     masterlog = mastercnf.get('log')
     self.root = PBRoot()
     rootservice = services.Service("rootservice")
     self.root.addServiceChannel(rootservice)
     self.webroot = vhost.NameVirtualHost()
     self.webroot.addHost('0.0.0.0', './')
     GlobalObject().root = self.root
     GlobalObject().webroot = self.webroot
     if masterlog:
         log.addObserver(loogoo(masterlog))  #日志处理
     log.startLogging(sys.stdout)
     import firefly.master.webapp
     import firefly.master.rootapp
     reactor.listenTCP(webport,
                       DelaySite(self.webroot),
                       interface='127.0.0.1')
     reactor.listenTCP(rootport, BilateralFactory(self.root))
Ejemplo n.º 2
0
 def masterapp(self):
     config = json.load(open(self.configpath,'r'))
     mastercnf = config.get('master')
     rootport = mastercnf.get('rootport')
     webport = mastercnf.get('webport')
     masterlog = mastercnf.get('log')
     self.root = PBRoot()
     rootservice = services.Service("rootservice")
     self.root.addServiceChannel(rootservice)
     self.webroot = vhost.NameVirtualHost()
     self.webroot.addHost('0.0.0.0', './')
     GlobalObject().root = self.root
     GlobalObject().webroot = self.webroot
     if masterlog:
         log.addObserver(loogoo(masterlog))#日志处理
     log.startLogging(sys.stdout)
     import webapp
     import rootapp
     reactor.listenTCP(webport, Site(self.webroot))
     reactor.listenTCP(rootport, BilateralFactory(self.root))
Ejemplo n.º 3
0
    def masterapp(self):
        # get config
        config = json.load(open(self.configpath,'r'))
        GlobalObject().json_config = config
        mastercnf = config.get('master')
        rootport = mastercnf.get('rootport')
        webport = mastercnf.get('webport')
        masterlog = mastercnf.get('log')
        webroot = mastercnf.get('webroot')

        # create root and webroot
        self.root = PBRoot()
        rootservice = services.Service("rootservice")
        self.root.addServiceChannel(rootservice)
        self.webroot = vhost.NameVirtualHost()

        # save root and webroot to global
        GlobalObject().root = self.root
        GlobalObject().webroot = self.webroot

        # add root resource, the webroot can be customized
        if webroot:
            parts = webroot.split('.')
            cls = parts[-1]
            pkg = '.'.join(parts[0:-1])
            module = __import__(pkg, fromlist = [cls])
            clsObj = getattr(module, cls)
            self.webroot.addHost('localhost', clsObj())
        else:
            self.webroot.addHost('localhost', DefaultMasterDirectory())

        if masterlog:
            log.addObserver(loogoo(masterlog))#日志处理
        log.startLogging(sys.stdout)
        import rootapp
        reactor.listenTCP(webport, DelaySite(self.webroot))
        reactor.listenTCP(rootport, BilateralFactory(self.root))
Ejemplo n.º 4
0
    def masterapp(self):
        """
        """
        config = json.load(open(self.configpath, "r"))
        GlobalObject().json_config = config
        mastercnf = config.get("master")
        rootport = mastercnf.get("rootport")
        webport = mastercnf.get("webport")
        masterlog = mastercnf.get("log")
        self.root = PBRoot()
        rootservice = services.Service("rootservice")
        self.root.addServiceChannel(rootservice)
        self.webroot = vhost.NameVirtualHost()
        self.webroot.addHost("0.0.0.0", "./")
        GlobalObject().root = self.root
        GlobalObject().webroot = self.webroot
        if masterlog:
            log.addObserver(loogoo(masterlog))  # 日志处理
        log.startLogging(sys.stdout)
        from . import webapp
        from . import rootapp

        reactor.listenTCP(webport, DelaySite(self.webroot))
        reactor.listenTCP(rootport, BilateralFactory(self.root))
Ejemplo n.º 5
0

###########################################################################################

msgdistribute = GlobalObject().json_config.get("msgdistribute")
msgrule = msgdistribute.get('rule')
msgdefault = msgdistribute.get('default')
servername = GlobalObject().json_config.get("name")
iswebsocket = GlobalObject().json_config.get("iswebsocket", False)
if iswebsocket:
    GlobalObject().netfactory.protocol = websocket.WebSocketHandler
logpath = GlobalObject().json_config.get('log')
servername = GlobalObject().json_config.get('name')
if logpath:
    if logpath:
        log.addObserver(loogoo(logpath))  #日志处理
    log.startLogging(sys.stdout)

###########################################################################################

netservice = NetCommandService("loginService")
GlobalObject().netfactory.addServiceChannel(netservice)


class Session:
    def __init__(self, sid, servename):
        self.session = '%s,%d' % (servename, sid)

    def getsession(self):
        return self.session