Documentation
¶
Index ¶
- Variables
- func AbandonStartedDaemon(child *exec.Cmd)
- func AcquireDaemonLifecycleLock() (*os.File, error)
- func AcquireDaemonLifecycleLockAt(path string) (*os.File, error)
- func ActiveWingRelayHTTPURL(cfg *config.Config, status *WingStatus) string
- func DaemonAbsentError(err error) bool
- func ParseSavedDaemonArgs(data []byte, kind DaemonKind) ([]string, error)
- func ReadPid() (int, error)
- func ReadPidFrom(path string, kind DaemonKind) (int, error)
- func RestartWingDaemonIfRunning() error
- func RoostArgsPath() string
- func RoostLogPath() string
- func RoostPidPath() string
- func RotateLog(path string) error
- func SignalDaemon(sig os.Signal) error
- func StopDaemonAndWait(pid int, kind DaemonKind, timeout time.Duration) error
- func WaitForWingStatus(pid int, timeout time.Duration) string
- func WingArgsPath() string
- func WingLogPath() string
- func WingPidPath() string
- func WingStatusPath() string
- func WriteAtomicMetadataFile(path string, data []byte, mode os.FileMode) error
- func WriteDaemonMetadata(pidPath, argsPath string, pid int, args []string) error
- func WriteWingStatusForRoost(state, lastErr, roostURL string)
- type DaemonKind
- type WingStatus
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoDaemonRunning = errors.New("no daemon running")
)
Functions ¶
func AbandonStartedDaemon ¶
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 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 ParseSavedDaemonArgs ¶
func ParseSavedDaemonArgs(data []byte, kind DaemonKind) ([]string, error)
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 ¶
rotateLog rotates path when it exceeds maxLogSize. Chain: .log -> .log.1 -> .log.2.gz -> deleted
func SignalDaemon ¶
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 ¶
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 WriteDaemonMetadata ¶
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)