    async def start_service(
        self,
        service_name: str,
        service: Service,
        ssl_context: Optional[ssl.SSLContext] = None,
    ) -> bool:
        """Start a managed service or poll for external service

        Args:
            service_name (str): Name of the service.
            service (Service): The service object.

        Returns:
            boolean: Returns `True` if the service is started successfully,
            returns `False` otherwise.
        """
        if ssl_context is None:
            ssl_context = make_ssl_context(
                self.internal_ssl_key,
                self.internal_ssl_cert,
                cafile=self.internal_ssl_ca,
                purpose=ssl.Purpose.CLIENT_AUTH,
            )

        msg = f'{service_name} at {service.url}' if service.url else service_name
        if service.managed:
            self.log.info("Starting managed service %s", msg)
            try:
                await service.start()
            except Exception as e:
                self.log.critical(
                    "Failed to start service %s", service_name, exc_info=True
                )
                return False
        else:
            self.log.info("Adding external service %s", msg)

        if service.url:
            tries = 10 if service.managed else 1
            for i in range(tries):
                try:
                    await Server.from_orm(service.orm.server).wait_up(
                        http=True, timeout=1, ssl_context=ssl_context
                    )
                except AnyTimeoutError:
                    if service.managed:
                        status = await service.spawner.poll()
                        if status is not None:
                            self.log.critical(
                                "Service %s exited with status %s",
                                service_name,
                                status,
                            )
                            return False
                else:
                    return True
            else:
                if service.managed:
                    self.log.critical(
                        "Cannot connect to %s service %s",
                        service_name,
                        service.kind,
                    )
                else:
                    self.log.warning(
                        "Cannot connect to %s service %s at %s. Is it running?",
                        service.kind,
                        service_name,
                        service.url,
                    )
                return False
        return True
Start a managed service or poll for external service

Args:
service_name (str): Name of the service.
service (Service): The service object.

Returns:
boolean: Returns `True` if the service is started successfully,
returns `False` otherwise.
jupyterhub/app.py