Documentation
¶
Index ¶
- Variables
- func AbandonStartedDaemon(child *exec.Cmd)
- func AcquireDaemonLifecycleLock() (*os.File, error)
- func AcquireDaemonLifecycleLockAt(path string) (*os.File, error)
- func AcquireDaemonLifecycleLockAtContext(ctx context.Context, path string) (*os.File, error)
- func AcquireDaemonLifecycleLockContext(ctx context.Context) (*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 RestartWingDaemonAfterLogin() 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 ErrDaemonLifecycleBusy = errors.New("another daemon start/stop is already in progress")
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 AcquireDaemonLifecycleLockAtContext ¶ added in v0.149.4
func AcquireDaemonLifecycleLockContext ¶ added in v0.149.4
AcquireDaemonLifecycleLockContext lets implicit startup callers join an existing lifecycle operation without nesting locks or ignoring cancellation. Explicit start/stop commands retain their nonblocking lock behavior.
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 RestartWingDaemonAfterLogin ¶ added in v0.149.4
func RestartWingDaemonAfterLogin() error
RestartWingDaemonAfterLogin enables the relay explicitly requested by wt login. Existing state, key, roost and session configuration remain the same.
func RestartWingDaemonIfRunning ¶
func RestartWingDaemonIfRunning() error
RestartWingDaemonIfRunning preserves the running wing's transport choice.
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)