serveaddr

package
v0.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package serveaddr owns the home-root run directory that a live `gadak serve` writes so other processes can find it without guessing ports.

These files answer which loopback ports currently serve the UI. They are not leftover serve-origin.json (ignored since GDK-936) and they do not grant origin-write ownership.

Index

Constants

View Source
const Rel = "run"

Rel is the directory name under the gadak home root.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir is <gadak-home>/run, shared across workspaces. findServeTarget prefers a same-profile hit and falls back to any other live serve, so discovery must see every profile's serve — not only the caller's profile directory (config.Dir()). config.DirFor("") is the home root.

func Path

func Path(dir, port string) string

Path is the runtime file for one port inside dir.

func Publish

func Publish(addr, profile string) (func(), error)

Publish writes the bound address into Dir and returns a cleanup that removes that file. Callers that must not take the server down on a write failure log err and continue.

func Remove

func Remove(dir, port string) error

Remove deletes the runtime file for port. Missing is not an error — a crash leftover is the other path, and the next probe treats a dead file as "no live serve".

func Write

func Write(dir, addr, profile string) error

Write publishes the bound listen address. Atomic write (temp + rename) at 0600, same as config.Save. The filename is the port so two serves cannot collide.

Types

type Record

type Record struct {
	Addr      string `json:"addr"`
	Profile   string `json:"profile"`
	PID       int    `json:"pid"`
	StartedAt string `json:"startedAt"`
	Port      string `json:"-"`
}

Record is one live-serve file. Addr is the bound listen address (after port fallback), not the preferred --addr. Port is the file key (from the filename) and is not stored in the JSON.

func List

func List(dir string) []Record

List reads every port-named file in dir. Missing or unreadable dir is empty, not an error: discovery then falls back to the port sweep.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL