class_docstr: Nginx keeps track of registered domains, updates nginx config and issues SSL certificates.
  Its internal state could be serialized to a file and restored from it using pydantic.
class_docstr_tok: ["Nginx","keeps","track","of","registered","domains",",","updates","nginx","config","and","issues","SSL","certificates",".","Its","internal","state","could","be","serialized","to","a","file","and","restored","from","it","using","pydantic","."]
code: def write_conf(cls, conf: dict, conf_path: Path):
      temp = tempfile.NamedTemporaryFile("w")
      temp.write(cls.format_conf(conf))
      temp.flush()
      temp.seek(0)
      r = subprocess.run(["sudo", "cp", temp.name, conf_path])
      if r.returncode != 0:
          raise GatewayError("Failed to write nginx config")
  
file_path: dstack/gateway/src/dstack/gateway/services/nginx.py
imports: import logging
  import re
  import subprocess
  import tempfile
  from asyncio import Lock
  from functools import lru_cache
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  from pydantic import BaseModel
  from dstack.gateway.common import run_async
  from dstack.gateway.errors import GatewayError
label_desc: Use image node_id 6 for calling the Nginx obj's underlying member method code with example usage: obj.write_conf(cls, conf, conf_path) without return types