def testRestartability(self): ws = HttpServer(TestConfiguration.create_instance()) self.assertFalse(self._isPortReserved(8888)) thread = threading.Thread(target=ws.start) thread.start() while (not ws.is_running()): time.sleep(0.01) self.assertTrue(self._isPortReserved(8888)) ws.stop() thread.join(10) self.assertFalse(self._isPortReserved(8888))
class AppServerFixture(Fixture): def __init__(self, config=None, projectDir=None): sys.path.insert(0, projectDir) self.config = config or TestConfiguration.create_instance() j25.config = self.config def loadApplication(self, application): self.appploader.load_application(application, j25._dispatcher) 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) def tearDown(self): logging.info('STOPING the Application server') self.ws.stop() logging.info("Waiting for Application Server to terminate...") self.thread.join(60) logging.info("Application Server terminated") self.dispatcher = None
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()
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)