Maps dala's per-device ports and finds host-side squatters.
Two failure modes this makes visible:
- A stale process (old iproxy, leftover dev server, a previous app instance) is already listening on a port the next device needs.
- You can't remember which dist/LV port belongs to which device when something misbehaves.
Port model:
- EPMD — 4369, shared by all devices on the host
- dist —
Tunnel.dist_port(index)(9100 + index) per discovered device, using the same index order as the deployer/connector - LiveView — hashed from the app name in [4200..4999], matching the
hash-based port allocation in
Dala.LiveView.local_url/1
Summary
Functions
Kills the given host PIDs with SIGKILL. Returns count actually signalled.
Returns pids of host processes listening on port, as integers.
Empty list means the port is free. Uses lsof (macOS/Linux).
Expected LiveView port for this project — same formula as dala's hash-based
default (4200 + rem(phash2(app_name), 800)). Public for testing.
Builds the expected port map for currently connected devices. Android devices come first (deployer index order), then iOS.
Types
@type entry() :: %{ device: String.t(), id: String.t() | nil, kind: :epmd | :dist | :liveview, port: non_neg_integer(), node: atom() | nil }
One expected port binding: which device uses it and for what.
Functions
@spec kill_pids([non_neg_integer()]) :: non_neg_integer()
Kills the given host PIDs with SIGKILL. Returns count actually signalled.
@spec listeners_on(non_neg_integer()) :: [non_neg_integer()]
Returns pids of host processes listening on port, as integers.
Empty list means the port is free. Uses lsof (macOS/Linux).
@spec liveview_port() :: non_neg_integer()
Expected LiveView port for this project — same formula as dala's hash-based
default (4200 + rem(phash2(app_name), 800)). Public for testing.
@spec port_map((-> [DalaDev.Device.t()])) :: [entry()]
Builds the expected port map for currently connected devices. Android devices come first (deployer index order), then iOS.
lister/0 overrides discovery (test seam — mirrors
NativeBuild.narrow_platforms_for_device/3).