| 44 | |
| 45 | |
| 46 | def get_endpoint(endpoint: str | None = None) -> str: |
| 47 | if endpoint: |
| 48 | return endpoint |
| 49 | if "DSTACK_SIMULATOR_ENDPOINT" in os.environ: |
| 50 | logger.info( |
| 51 | f"Using simulator endpoint: {os.environ['DSTACK_SIMULATOR_ENDPOINT']}" |
| 52 | ) |
| 53 | return os.environ["DSTACK_SIMULATOR_ENDPOINT"] |
| 54 | # Try paths in order: legacy paths first, then namespaced paths |
| 55 | socket_paths = [ |
| 56 | "/var/run/dstack.sock", |
| 57 | "/run/dstack.sock", |
| 58 | "/var/run/dstack/dstack.sock", |
| 59 | "/run/dstack/dstack.sock", |
| 60 | ] |
| 61 | for path in socket_paths: |
| 62 | if os.path.exists(path): |
| 63 | return path |
| 64 | # Default to new path even if not exists (will fail with clear error) |
| 65 | return socket_paths[0] |
| 66 | |
| 67 | |
| 68 | def get_tappd_endpoint(endpoint: str | None = None) -> str: |