def __enter__(self): server_log_handler = self.server_logging_ctx.__enter__() self.config_ctx = self.build_config() self.config = self.config_ctx.__enter__() self.stash.__enter__() self.cache_manager.__enter__() assert self.env_extras_cms is None, ( "A TestEnvironment object cannot be nested") self.env_extras_cms = [] for env in self.env_extras: cm = env(self.options, self.config) cm.__enter__() self.env_extras_cms.append(cm) self.servers = serve.start(self.server_logger, self.config, self.get_routes(), mp_context=mpcontext.get_context(), log_handlers=[server_log_handler], webtransport_h3=self.enable_webtransport) if self.options.get( "supports_debugger" ) and self.debug_info and self.debug_info.interactive: self.ignore_interrupts() return self
def main(self): kwargs = vars(serve.get_parser().parse_args()) # Configuration script to setup server used for serving web platform tests. config = serve.load_config( os.path.join(WPT_DIR, 'config.default.json'), os.path.join(WPT_DIR, 'config.json'), **kwargs) config['ports']['http'][0] = int(self._wpt_http_port) serve.setup_logger(config['log_level']) with stash.StashServer((self._binding_address, serve.get_port()), authkey=str(uuid.uuid4())): with serve.get_ssl_environment(config) as ssl_env: _, self._servers = serve.start(config, ssl_env, serve.default_routes(), **kwargs) self._server_started = True try: while any(item.is_alive() for item in serve.iter_procs(self._servers)): for item in serve.iter_procs(self._servers): item.join(1) except KeyboardInterrupt: serve.logger.info('Shutting down')
def __enter__(self): self.stash.__enter__() self.ssl_env.__enter__() self.cache_manager.__enter__() self.config = self.load_config() self.setup_server_logging() ports = serve.get_ports(self.config, self.ssl_env) self.config = serve.normalise_config(self.config, ports) assert self.env_extras_cms is None, ( "A TestEnvironment object cannot be nested") self.env_extras_cms = [] for env in self.env_extras: cm = env(self.options, self.config) cm.__enter__() self.env_extras_cms.append(cm) self.servers = serve.start(self.config, self.ssl_env, self.get_routes()) if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive: self.ignore_interrupts() return self
def main(argv, stdout, stderr): # This is a copy of serve.py main function, except for the wait step config = WebPlatformTestServer.load_config("config.default.json", "config.json") WebPlatformTestServer.setup_logger(config["log_level"]) logged_servers = [] with stash.StashServer((config["host"], WebPlatformTestServer.get_port()), authkey=str(uuid.uuid4())): with WebPlatformTestServer.get_ssl_environment(config) as ssl_env: config_, started_servers = WebPlatformTestServer.start( config, ssl_env, WebPlatformTestServer.default_routes()) for protocol, servers in started_servers.items(): for port, process in servers: logged_servers.append({ "protocol": protocol, "port": port, "pid": process.proc.pid }) logger.info("%s, port:%d, pid:%d" % (protocol, port, process.proc.pid)) # Write pids in a file in case abrupt shutdown is needed with open(argv[0], "wb") as servers_file: json.dump(logged_servers, servers_file) sys.stdin.read(1)
def __enter__(self): self.ssl_env.__enter__() self.cache_manager.__enter__() self.setup_server_logging() self.setup_routes() self.config = self.load_config() serve.set_computed_defaults(self.config) self.external_config, self.servers = serve.start(self.config, self.ssl_env) return self
def __enter__(self): self.ssl_env.__enter__() self.cache_manager.__enter__() self.setup_server_logging() self.config = self.load_config() serve.set_computed_defaults(self.config) self.external_config, self.servers = serve.start(self.config, self.ssl_env, self.routes) return self
def __enter__(self): self.ssl_env.__enter__() self.cache_manager.__enter__() self.setup_server_logging() self.config = self.load_config() serve.set_computed_defaults(self.config) self.external_config, self.servers = serve.start(self.config, self.ssl_env, self.routes) if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive: self.ignore_interrupts() return self
def __enter__(self): self.stash.__enter__() self.ssl_env.__enter__() self.cache_manager.__enter__() for cm in self.env_extras: cm.__enter__(self.options) self.setup_server_logging() self.config = self.load_config() ports = serve.get_ports(self.config, self.ssl_env) self.config = serve.normalise_config(self.config, ports) self.servers = serve.start(self.config, self.ssl_env, self.get_routes()) if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive: self.ignore_interrupts() return self
def __enter__(self): self.stash.__enter__() self.ssl_env.__enter__() self.cache_manager.__enter__() for cm in self.env_extras: cm.__enter__(self.options) self.setup_server_logging() self.config = self.load_config() ports = serve.get_ports(self.config, self.ssl_env) self.config = serve.normalise_config(self.config, ports) self.servers = serve.start(self.config, self.ssl_env, self.get_routes()) if self.options.get( "supports_debugger" ) and self.debug_info and self.debug_info.interactive: self.ignore_interrupts() return self
def main(argv, stdout, stderr): # This is a copy of serve.py main function, except for the wait step config = WebPlatformTestServer.load_config("config.default.json", "config.json") WebPlatformTestServer.setup_logger(config["log_level"]) logged_servers = [] with stash.StashServer((config["host"], WebPlatformTestServer.get_port()), authkey=str(uuid.uuid4())): with WebPlatformTestServer.get_ssl_environment(config) as ssl_env: config_, started_servers = WebPlatformTestServer.start(config, ssl_env, WebPlatformTestServer.default_routes()) for protocol, servers in started_servers.items(): for port, process in servers: logged_servers.append({"protocol": protocol, "port": port, "pid": process.proc.pid}) logger.info("%s, port:%d, pid:%d" % (protocol, port, process.proc.pid)) # Write pids in a file in case abrupt shutdown is needed with open(argv[0], "wb") as servers_file: json.dump(logged_servers, servers_file) sys.stdin.read(1)