portalCfg = serverMgmtIn.serverCfg
    serverMgmt = serverMgmtIn
    app = MyApplication(urls, globals())


    webthread = myThread(app, portalCfg.mgmtPort)
    webthread.start()



if __name__ == "__main__":

    global serverMgmt
    global portalCfg
    global clientMgmt
    global portalServerThread

    portalCfg = myPortalCfg()
    clientMgmt = portalClientMgmt(portalCfg)

    #print globals()
    serverMgmt = portalServerMgmt()
    serverMgmt.serverCfg =  portalCfg
    serverMgmt.clientMgmt = portalClientMgmt(serverMgmt.serverCfg)
    serverMgmt.portalServerLaunch()

    time.sleep(0.1)

    launchMain()

        #print "global", globals()
        func = self.wsgifunc(*middleware)
        return web.httpserver.runsimple(func, ('0.0.0.0', port))


class myThread (threading.Thread):
    def __init__(self, webApp, port):
        threading.Thread.__init__(self)
        self.webApp = webApp
        self.port = port

    def run(self):
        self.webApp.run(self.port)
        print "thread done"

    def stop(self):
        self.webApp.stop()

if __name__ == "__main__":

    global portalCfg
    global udpSocket
    global receiver
    global clientMgmt

    portalCfg = myPortalCfg()
    clientMgmt = portalClientMgmt(portalCfg)
    launchPortalWeb()