daemonctl

package
v0.149.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDaemonRunning = errors.New("no daemon running")
)

Functions

func AbandonStartedDaemon

func AbandonStartedDaemon(child *exec.Cmd)

abandonStartedDaemon terminates and reaps a child whose startup could not be committed to disk. This prevents a successful exec from becoming an invisible daemon when readiness or metadata persistence fails.

func AcquireDaemonLifecycleLock

func AcquireDaemonLifecycleLock() (*os.File, error)

func AcquireDaemonLifecycleLockAt

func AcquireDaemonLifecycleLockAt(path string) (*os.File, error)

func ActiveWingRelayHTTPURL

func ActiveWingRelayHTTPURL(cfg *config.Config, status *WingStatus) string

activeWingRelayHTTPURL uses the exact coordinator recorded by a new daemon, then falls back to saved launch args for an already-running older daemon.

func DaemonAbsentError

func DaemonAbsentError(err error) bool

func ParseSavedDaemonArgs

func ParseSavedDaemonArgs(data []byte, kind DaemonKind) ([]string, error)

func ReadPid

func ReadPid() (int, error)

readPid tries wing.pid first, then roost.pid. Returns the first live daemon PID.

func ReadPidFrom

func ReadPidFrom(path string, kind DaemonKind) (int, error)

readPidFrom reads a PID from a specific file and verifies that it still identifies the expected wt foreground daemon. PIDs are recycled, so merely finding a live same-UID process is not enough before callers send signals.

func RestartWingDaemonIfRunning

func RestartWingDaemonIfRunning() error

restartWingDaemonIfRunning stops the running wing daemon and starts a new one with the same args so it picks up the new auth token.

func RoostArgsPath

func RoostArgsPath() string

func RoostLogPath

func RoostLogPath() string

func RoostPidPath

func RoostPidPath() string

func RotateLog

func RotateLog(path string) error

rotateLog rotates path when it exceeds maxLogSize. Chain: .log -> .log.1 -> .log.2.gz -> deleted

func SignalDaemon

func SignalDaemon(sig os.Signal) error

func StopDaemonAndWait

func StopDaemonAndWait(pid int, kind DaemonKind, timeout time.Duration) error

stopDaemonAndWait revalidates the daemon command immediately before signaling it, then waits until that specific daemon identity is gone. This keeps the lifecycle lock meaningful: callers must not delete metadata and allow a replacement to start while the old listener is still shutting down.

func WaitForWingStatus

func WaitForWingStatus(pid int, timeout time.Duration) string

waitForWingStatus polls wing.status for up to timeout, returning the final state. Returns "local", "connected", "auth_failed", "exited", or "" (timeout).

func WingArgsPath

func WingArgsPath() string

func WingLogPath

func WingLogPath() string

func WingPidPath

func WingPidPath() string

func WingStatusPath

func WingStatusPath() string

func WriteAtomicMetadataFile

func WriteAtomicMetadataFile(path string, data []byte, mode os.FileMode) error

func WriteDaemonMetadata

func WriteDaemonMetadata(pidPath, argsPath string, pid int, args []string) error

func WriteWingStatusForRoost

func WriteWingStatusForRoost(state, lastErr, roostURL string)

Types

type DaemonKind

type DaemonKind string
const (
	WingDaemon  DaemonKind = "wing"
	RoostDaemon DaemonKind = "roost"
)

func ReadDaemon

func ReadDaemon() (int, DaemonKind, error)

readDaemon returns the one live daemon represented by local metadata. A healthy installation cannot run a standalone wing and a roost at once. If both metadata files identify live daemons, fail closed so lifecycle commands do not stop an arbitrary half of the conflicting installation.

type WingStatus

type WingStatus struct {
	State    string `json:"state"` // local, connecting, connected, auth_failed, disconnected
	Error    string `json:"error,omitempty"`
	TS       string `json:"ts"`
	RoostURL string `json:"roost_url,omitempty"`
}

wingStatus is the JSON schema for wing.status.

func ReadWingStatus

func ReadWingStatus() (*WingStatus, error)

Jump to

Keyboard shortcuts

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