async def run(self) -> None: lockfile = singleton( service_launch_lock_path(self.root_path, self._service_name)) if lockfile is None: self._log.error(f"{self._service_name}: already running") raise ValueError(f"{self._service_name}: already running") await self.start() await self.wait_closed()
async def setup_daemon(btools): root_path = btools.root_path config = btools.config lockfile = singleton(daemon_launch_lock_path(root_path)) crt_path = root_path / config["daemon_ssl"]["private_crt"] key_path = root_path / config["daemon_ssl"]["private_key"] ca_crt_path = root_path / config["private_ssl_ca"]["crt"] ca_key_path = root_path / config["private_ssl_ca"]["key"] assert lockfile is not None create_server_for_daemon(btools.root_path) ws_server = WebSocketServer(root_path, ca_crt_path, ca_key_path, crt_path, key_path) await ws_server.start() yield ws_server await ws_server.stop()