service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service runs the proxy in the background: start spawns a detached copy of this binary, records its PID and address, and waits for it to bind; stop and status find it again through that record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectHost

func ConnectHost(ip net.IP) net.IP

ConnectHost turns a bind address into one a client can dial.

func Dir

func Dir() (string, error)

Dir is where the record and the background log live: COMFY_API_PROXY_STATE_DIR (the reference's override), else $XDG_STATE_HOME/comfy-api-proxy, else ~/.local/state/comfy-api-proxy.

func LogPath

func LogPath() (string, error)

LogPath is the background process's log file.

func Stop

func Stop() (int, error)

Stop ends the recorded proxy. It reports the PID it stopped, or 0 when nothing of ours was running, which is not an error.

func URL

func URL(ip net.IP, port int) string

URL is the base URL for a bind address.

Types

type AlreadyRunningError

type AlreadyRunningError struct{ Rec Record }

AlreadyRunningError means start found a live proxy of ours.

func (*AlreadyRunningError) Error

func (e *AlreadyRunningError) Error() string

type Health

type Health struct {
	Status   string `json:"status"`
	Upstream string `json:"upstream"`
}

Health is what GET /api/v2/health reported.

func Probe

func Probe(ctx context.Context, baseURL string) (Health, error)

Probe asks a running proxy for its health.

type PortBusyError

type PortBusyError struct{ URL string }

PortBusyError means start found the port held by something else.

func (*PortBusyError) Error

func (e *PortBusyError) Error() string

type Record

type Record struct {
	PID int `json:"pid"`
	// Exe is the binary start launched. A PID counts as ours only while it
	// still runs that binary, so a recycled PID is never signalled.
	Exe  string `json:"exe,omitempty"`
	Host string `json:"host"`
	Port int    `json:"port"`
	URL  string `json:"url"`
}

Record is what start leaves behind in proxy.json.

func Read

func Read() (*Record, error)

Read returns the saved record. A missing, corrupt, or oddly shaped record reads as nil: status and stop treat it as "not running" instead of failing.

func Running

func Running() (*Record, error)

Running returns the live record, or nil when nothing of ours is running.

func Start

func Start(args []string, host string, ip net.IP, port int) (Record, string, error)

Start launches this binary with "run" plus args, detached from the terminal, and waits for it to listen on ip:port.

Jump to

Keyboard shortcuts

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