def run(**kwargs): config = load_config(os.path.join(repo_root, "config.json"), **kwargs) global logger logger = config.logger set_logger(logger) bind_address = config["bind_address"] if config["check_subdomains"]: check_subdomains(config) stash_address = None if bind_address: stash_address = (config.server_host, get_port(config.server_host)) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, config.ssl_env, build_routes(config["aliases"]), **kwargs) try: while any(item.is_alive() for item in iter_procs(servers)): for item in iter_procs(servers): item.join(1) except KeyboardInterrupt: logger.info("Shutting down")
def run(**kwargs): with build_config(os.path.join(repo_root, "config.json"), **kwargs) as config: global logger logger = config.logger set_logger(logger) bind_address = config["bind_address"] if kwargs.get("alias_file"): with open(kwargs["alias_file"], 'r') as alias_file: for line in alias_file: alias, doc_root = [x.strip() for x in line.split(',')] config["aliases"].append({ 'url-path': alias, 'local-dir': doc_root, }) if config["check_subdomains"]: check_subdomains(config) stash_address = None if bind_address: stash_address = (config.server_host, get_port("")) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, build_routes(config["aliases"]), **kwargs) try: while any(item.is_alive() for item in iter_procs(servers)): for item in iter_procs(servers): item.join(1) except KeyboardInterrupt: logger.info("Shutting down")
def run(**kwargs): received_signal = threading.Event() with build_config(os.path.join(repo_root, "config.json"), **kwargs) as config: global logger logger = config.logger set_logger(logger) # Configure the root logger to cover third-party libraries. logging.getLogger().setLevel(config.log_level) def handle_signal(signum, frame): logger.debug("Received signal %s. Shutting down.", signum) received_signal.set() bind_address = config["bind_address"] if kwargs.get("alias_file"): with open(kwargs["alias_file"], 'r') as alias_file: for line in alias_file: alias, doc_root = [x.strip() for x in line.split(',')] config["aliases"].append({ 'url-path': alias, 'local-dir': doc_root, }) if config["check_subdomains"]: check_subdomains(config) stash_address = None if bind_address: stash_address = (config.server_host, get_port("")) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, build_routes(config["aliases"]), **kwargs) signal.signal(signal.SIGTERM, handle_signal) signal.signal(signal.SIGINT, handle_signal) while (all(subproc.is_alive() for subproc in iter_procs(servers)) and not received_signal.is_set()): for subproc in iter_procs(servers): subproc.join(1) failed_subproc = 0 for subproc in iter_procs(servers): if subproc.is_alive(): logger.info('Status of subprocess "%s": running' % subproc.name) else: if subproc.exitcode == 0: logger.info( 'Status of subprocess "%s": exited correctly' % subproc.name) else: logger.warning( 'Status of subprocess "%s": failed. Exit with non-zero status: %d' % (subproc.name, subproc.exitcode)) failed_subproc += 1 return failed_subproc
def ensure_logger(config): global logger try: logger except NameError: logger = config.logger set_logger(logger)
def run(**kwargs): with build_config(os.path.join(repo_root, "config.json"), **kwargs) as config: global logger logger = config.logger set_logger(logger) bind_address = config["bind_address"] if kwargs.get("alias_file"): with open(kwargs["alias_file"], 'r') as alias_file: for line in alias_file: alias, doc_root = [x.strip() for x in line.split(',')] config["aliases"].append({ 'url-path': alias, 'local-dir': doc_root, }) if config["check_subdomains"]: check_subdomains(config) stash_address = None if bind_address: stash_address = (config.server_host, get_port("")) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, build_routes(config["aliases"]), **kwargs) try: while any(item.is_alive() for item in iter_procs(servers)): for item in iter_procs(servers): item.join(1) except KeyboardInterrupt: logger.info("Shutting down")
def setup_logger(level): import logging global logger logger = logging.getLogger("web-platform-tests") logging.basicConfig(level=getattr(logging, level.upper())) set_logger(logger)
def run(**kwargs): received_signal = threading.Event() with build_config(os.path.join(repo_root, "config.json"), **kwargs) as config: global logger logger = config.logger set_logger(logger) # Configure the root logger to cover third-party libraries. logging.getLogger().setLevel(config.log_level) def handle_signal(signum, frame): logger.debug("Received signal %s. Shutting down.", signum) received_signal.set() bind_address = config["bind_address"] if kwargs.get("alias_file"): with open(kwargs["alias_file"], 'r') as alias_file: for line in alias_file: alias, doc_root = [x.strip() for x in line.split(',')] config["aliases"].append({ 'url-path': alias, 'local-dir': doc_root, }) if config["check_subdomains"]: check_subdomains(config) stash_address = None if bind_address: stash_address = (config.server_host, get_port("")) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, build_routes(config["aliases"]), **kwargs) signal.signal(signal.SIGTERM, handle_signal) signal.signal(signal.SIGINT, handle_signal) while (all(item.is_alive() for item in iter_procs(servers)) and not received_signal.is_set()): for item in iter_procs(servers): item.join(1) exited = [ item for item in iter_procs(servers) if not item.is_alive() ] subject = "subprocess" if len(exited) == 1 else "subprocesses" logger.info("%s %s exited:" % (len(exited), subject)) for item in iter_procs(servers): logger.info("Status of %s:\t%s" % (item.name, "running" if item.is_alive() else "not running"))
def run(**kwargs): with build_config(os.path.join(repo_root, "config.json"), **kwargs) as config: global logger logger = config.logger set_logger(logger) bind_address = config["bind_address"] # Creating wave specific config if kwargs is_wave = true wave_cfg = None if kwargs.get("is_wave") is True: wave_cfg = { "is_wave": kwargs.get("is_wave"), "report": kwargs.get("report") } if kwargs.get("alias_file"): with open(kwargs["alias_file"], 'r') as alias_file: for line in alias_file: alias, doc_root = [x.strip() for x in line.split(',')] config["aliases"].append({ 'url-path': alias, 'local-dir': doc_root, }) if config["check_subdomains"]: # added wave_cfg to pass on to build_routes to init wave handler check_subdomains(config, wave_cfg) stash_address = None if bind_address: stash_address = (config.server_host, get_port("")) logger.debug("Going to use port %d for stash" % stash_address[1]) with stash.StashServer(stash_address, authkey=str(uuid.uuid4())): servers = start(config, build_routes(config["aliases"], wave_cfg), **kwargs) try: while all(item.is_alive() for item in iter_procs(servers)): for item in iter_procs(servers): item.join(1) exited = [item for item in iter_procs(servers) if not item.is_alive()] subject = "subprocess" if len(exited) == 1 else "subprocesses" logger.info("%s %s exited:" % (len(exited), subject)) for item in iter_procs(servers): logger.info("Status of %s:\t%s" % (item.name, "running" if item.is_alive() else "not running")) except KeyboardInterrupt: logger.info("Shutting down")
def setup_logger(level): import logging global logger logger = logging.getLogger("web-platform-tests") logging.basicConfig(level=getattr(logging, level.upper())) set_logger(logger)