Documentation
¶
Overview ¶
Package ports provides port-holder identification utilities for the nSelf CLI. It augments the raw TCP port probing in internal/docker with process-level information so that conflict error messages name the offending process.
Package ports provides canonical port constants for nSelf services and port-holder identification utilities for the nSelf CLI.
Purpose: Single source of truth for all nSelf service ports used by the CLI.
These constants must match F10-PORT-REGISTRY.md in the canonical SPORT.
Inputs: None (compile-time constants). Outputs: Typed int constants for use in CLI commands. Constraints: Never hardcode these values elsewhere in cli/; always import. SPORT: F10-PORT-REGISTRY.md — update both files together.
Index ¶
Constants ¶
const ( // AICCPort is the port for nself-ai-cc (Claude Code PTY session relay). // SPORT F10: nself-ai-cc | HTTP/WS | 3760 AICCPort = 3760 // AIGatewayPort is the port for nself-ai-gateway (AI provider key vault + router). // SPORT F10: nself-ai-gateway | HTTP | 3761 AIGatewayPort = 3761 // AIMCPPort is the port for nself-ai-mcp (MCP tool server). // SPORT F10: nself-ai-mcp | HTTP | 3762 AIMCPPort = 3762 )
AI gateway ports (E6 canonical trio).
Variables ¶
This section is empty.
Functions ¶
func FormatConflictMessage ¶
FormatConflictMessage formats a human-readable port conflict error message. Example: "port 5432 is held by postgres (pid 1234) — stop it or change POSTGRES_PORT" If holder is nil (port is free or detection unavailable), the message omits holder info.
Types ¶
type Holder ¶
type Holder struct {
PID int
Name string // process name (short, e.g. "postgres")
Command string // full command line
IsOurs bool // true if the holder is one of our own Docker containers
}
Holder describes the process that is listening on a TCP port.
func WhoHoldsPort ¶
WhoHoldsPort returns the process holding the given TCP port. Returns nil (not an error) if the port is free or if holder detection is unavailable on the current platform (e.g. lsof/ss not installed). A non-nil error is returned only for unexpected failures after a holder was partially identified.