runfile

package
v1.3.96 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package runfile manages JSON port files at ~/.ggcode/run/<sessionID>.json that allow external processes to discover and query running ggcode instances.

Each port file is keyed by session ID (not workspace), so multiple instances in the same workspace each get their own file. The port file contains the WebUI listen address, auth token, PID, session ID, and workspace.

External tools read these files, then query the WebUI's /api/status endpoint:

curl -H "Authorization: Bearer <token>" http://<addr>/api/status

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAddr

func FormatAddr(host string, port int) string

FormatAddr is a convenience helper that joins host and port.

func PID

func PID() int

PID is a convenience helper for the current process.

func Remove

func Remove(sessionID string)

Remove deletes the port file for the given session ID if it exists.

func Write

func Write(pf PortFile) error

Write creates or overwrites the port file for the given session atomically.

Types

type PortFile

type PortFile struct {
	Addr      string `json:"addr"`       // WebUI listen address (e.g. "127.0.0.1:54321")
	Token     string `json:"token"`      // Bearer auth token for WebUI API
	PID       int    `json:"pid"`        // OS process ID
	SessionID string `json:"session_id"` // ggcode session ID
	Workspace string `json:"workspace"`  // working directory
	Mode      string `json:"mode"`       // startup permission mode (supervised, auto, etc.)
}

PortFile is the JSON structure written to disk.

func Read

func Read(sessionID string) (*PortFile, error)

Read reads and parses the port file for the given session ID. Returns an error if the file doesn't exist or is stale (PID not alive).

func ReadAll

func ReadAll() ([]PortFile, error)

ReadAll reads all non-stale port files in ~/.ggcode/run/. Useful for listing all running instances.

func ReadForWorkspace

func ReadForWorkspace(workspace string) ([]PortFile, error)

ReadForWorkspace reads all non-stale port files matching the given workspace. Returns all instances running in that workspace.

Jump to

Keyboard shortcuts

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