def run_webgui(config): global SRVR_CFG global logger SRVR_CFG = ServerConfig(config) WebSocketLogger.REPLAY_NUM_MSGS = SRVR_CFG.cfg_get("replay_num_msgs", int, 10) Utils.temp_files_root = SRVR_CFG.cfg_get("temp_dir", str, None) log_lvl = SRVR_CFG.cfg_get("log_level", str, "DEBUG") log_lvl = getattr(logging, log_lvl) log_file = SRVR_CFG.cfg_get("log_file", str, None) logger = logging.getLogger('cloudCS') tornado_access_logger = logging.getLogger('tornado.access') tornado_application_logger = logging.getLogger('tornado.application') tornado_general_logger = logging.getLogger('tornado.general') logger.setLevel(log_lvl) tornado_access_logger.setLevel(log_lvl) tornado_application_logger.setLevel(log_lvl) tornado_general_logger.setLevel(log_lvl) if log_file: handler = logging.FileHandler(log_file) formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s', '%m/%d/%Y %I.%M.%S.%p') handler.setFormatter(formatter) logger.addHandler(handler) tornado_access_logger.addHandler(handler) tornado_application_logger.addHandler(handler) tornado_general_logger.addHandler(handler) else: logging.basicConfig() logger.info('starting up...') logger.debug("listening on - " + SRVR_CFG.listen_ip + ':' + str(SRVR_CFG.port)) logger.debug("hostname - " + SRVR_CFG.host) logger.debug("multiuser - " + str(SRVR_CFG.multiuser)) logger.debug("headless - " + str(SRVR_CFG.headless)) AsyncRunner.DEFAULT_REPLY = {'complete': True, 'success': False} if (Utils.temp_files_root != None): AsyncRunner.FILTER_STRINGS = [Utils.temp_files_root] AsyncRunner.LOG_MSG = WSMsg.SHOW_LOG app = Application() server = tornado.httpserver.HTTPServer(app) server.listen(SRVR_CFG.port, address=SRVR_CFG.listen_ip) if not SRVR_CFG.headless: webbrowser.open(SRVR_CFG.http_url) if SRVR_CFG.multiuser: # start the session and task timeout monitor app.start_session_and_task_monitor() try: tornado.ioloop.IOLoop.instance().start() except: logger.exception("server shutdown with exception") logger.info("shutting down...") try: Session.logout_all() except: logger.exception("exception while cleaning up") logger.info("server shut down")