launcher

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package launcher tracks running per-project Interseptor instances so a single dashboard process can start/stop/discover them: the registry is a small JSON file (~/.interseptor/instances.json) mapping project name to {controlAddr, proxyAddr, pid}, written by whichever process spawns an instance and pruned lazily via Reconcile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFreePort

func FindFreePort(host string, start, span int, used map[int]bool) (int, error)

FindFreePort returns the first TCP port in [start, start+span) that is not in used and can actually be bound on host right now, verified by a real listen-then-close probe — not just absence from used — so a port already held by an unrelated process is skipped too.

Types

type Instance

type Instance struct {
	Project     string `json:"project"`
	Dir         string `json:"dir,omitempty"`
	ControlAddr string `json:"controlAddr"`
	ProxyAddr   string `json:"proxyAddr"`
	PID         int    `json:"pid"`
	StartedAt   string `json:"startedAt,omitempty"`
}

Instance is one running project's control-plane/proxy addresses and pid.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a mutex-guarded, disk-backed set of running instances keyed by project name. Safe for concurrent use.

func Open

func Open(path string) (*Registry, error)

Open loads path if it exists; a missing or corrupt file yields an empty, otherwise-usable registry rather than an error, since a stale/garbled registry shouldn't block the launcher from starting.

func (*Registry) All

func (r *Registry) All() []Instance

All returns every recorded instance, sorted by project name.

func (*Registry) Get

func (r *Registry) Get(project string) (Instance, bool)

Get returns the recorded instance for project, if any.

func (*Registry) Reconcile

func (r *Registry) Reconcile(isAlive func(pid int) bool) error

Reconcile drops entries whose process is no longer alive, as judged by isAlive (injected so tests don't depend on real OS process state).

func (*Registry) Remove

func (r *Registry) Remove(project string) error

Remove drops project's entry (a no-op if absent) and persists the registry.

func (*Registry) Upsert

func (r *Registry) Upsert(inst Instance) error

Upsert records/replaces inst and persists the registry.

Jump to

Keyboard shortcuts

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