예제 #1
0
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)
예제 #2
0
    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 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)