示例#1
0
def main(configFile):
    from celery.bin import celeryd
    from j25.scripts import Server
    print Server.getBanner()
    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")

    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()
    
    celeryd.main()
 def testDefaults(self):
     config = Configuration.load_defaults()
     self.assertTrue(hasattr(config, "main"))
     self.assertEquals("0.0.0.0", config.main.ip)
     self.assertEquals(8800, int(config.main.port))
     self.assertEquals(10, int(config.main.num_threads))
     
     self.assertTrue(hasattr(config, "memcached"))
     self.assertEquals("127.0.0.1:11211", config.memcached.servers)
     self.assertEquals(0, config.memcached.expireTime)
     self.assertEquals(0, config.memcached.min_compress_len)
示例#3
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()