Esempio n. 1
0
def boot(configFile):
    logger = logging.getLogger("j25")
    logger.debug("Started with argv=%s", str(sys.argv))    
    if configFile:
        from j25.Configuration import Configuration
        config = Configuration.load_file(configFile)
    else:
        config = Configuration.load_defaults()
    
    import j25
    if config.main.mode == "DEV":
        Importer.enable()
        j25._reloader = Reloader(0.6)
        j25._reloader.start()
        logger.warning("\033[1;31mDEVELOPMENT MODE ACTIVE\033[0m")

    from j25.http.HttpServer import HttpServer
    from j25.http.RequestDispatcher import RequestDispatcher
    from j25.loaders import AppLoader
        
    logger.info("\033[1;33mProject: %s\033[0m", config.main.project_name)    
    #setting configuration global
    j25.config = config
    
    #init store
    logger.debug("Connecting to Database")
    j25.initStore()
        
    #create the dispatcher
    j25._dispatcher = RequestDispatcher(AppLoader.AutoAppLoader(eval(config.main.applications)))
    j25._create_routing_middleware()
    j25._dispatcher.load_applications()
    #run the server and loop forever
    ws = HttpServer(config)
    logger.info(getBanner())
    ws.start()
Esempio n. 2
0
 def setUp(self):
     setupLogging(logging.INFO)
     logger = logging.getLogger("j25")
     #setting configuration global
     j25.config = self.config
     
     #init store
     logger.debug("Connecting to Database")
     j25.initStore()
         
     #create the dispatcher
     self.appploader = AutoAppLoader([])
     j25._dispatcher = RequestDispatcher(self.appploader)
     j25._create_routing_middleware()
     j25._dispatcher.load_applications()
     #run the server and loop forever
     
     logging.info('STARTING the Application server')
     logger.info("\033[1;33mProject: %s\033[0m", self.config.main.project_name)
     self.ws = HttpServer(self.config)
     self.thread = threading.Thread(target=self.ws.start)
     self.thread.start()
     while (not self.ws.is_running()):
         time.sleep(0.01)