Expand description
Machine-wide shared quick-tunnel record, file-protocol compatible with
greentic-start (greentic-start/src/tunnel_state.rs).
A quick tunnel fronts exactly one local port, so one tunnel per (machine, port) is both necessary and sufficient. Setup and the runtime both honour a shared on-disk record instead of each spawning (and previously killing) their own cloudflared:
- pidfile:
<root>/state/pids/shared.cloudflared-<port>/cloudflared.pid - URL cache:
<root>/state/runtime/shared.cloudflared-<port>/public_base_url.txt - log:
<root>/logs/shared.cloudflared-<port>/cloudflared.log - spawn lock:
<root>/state/cloudflared-<port>.lock
<root> is ~/.greentic/tunnel (override: GREENTIC_TUNNEL_STATE_DIR).
greentic-setup does not depend on greentic-start, so this module
implements the same protocol independently; changing these paths is a
cross-repo protocol change. Only processes recorded here are ever
terminated — never by name.
Structs§
- Shared
Tunnel Paths - On-disk paths of the shared cloudflared record for one local port.
- Tunnel
Lock - Advisory file lock guarding the check-then-spawn critical section: exists while held, reclaimed when stale. Dropping releases it.
Functions§
- clear_
record - local_
port_ from_ base_ url - Local port a tunnel for
local_base_urlwould be keyed on. - probe_
tunnel_ alive - Probe with retries until
REUSE_PROBE_TIMEOUTelapses. - read_
record - Read the recorded (pid, url) pair; either half may be absent.
- shared_
tunnel_ paths - terminate_
recorded_ pid - Terminate the recorded process. Only ever called with a PID read from the shared record — ownership is proven by the record, never by process name.
- write_
record - Publish a spawned tunnel into the shared record so other Greentic processes (greentic-start in particular) reuse it instead of respawning.