Documentation
¶
Index ¶
- Constants
- func AutostartLogPath() (string, error)
- func CatalogOwns(s catalog.Service) bool
- func DialCompose(ctx context.Context, svcs []catalog.Service) (*composeclient.Client, error)
- func FollowFile(ctx context.Context, path string, w io.Writer) error
- func FollowStreams(ctx context.Context, s catalog.Service, which string, out chan<- string) error
- func FormatLaunchTable(rows []LaunchStatus) string
- func FormatPS(rows []LaunchStatus) string
- func InstallLoginAgent(LoginAgent) error
- func LocalHealthy(s catalog.Service, rep Report) bool
- func LocalReady(ctx context.Context, s catalog.Service) bool
- func Logs(ctx context.Context, s catalog.Service, which string, tail int, ...) error
- func NeedsCompose(svcs []catalog.Service) bool
- func ReadSince(path string, offset int64) ([]byte, int64, error)
- func ReadTail(path string, n int) ([]string, error)
- func Reap(args []string) error
- func Restart(ctx context.Context, cat *catalog.File, name string, w io.Writer) error
- func Start(ctx context.Context, s catalog.Service, w io.Writer) error
- func Stop(ctx context.Context, s catalog.Service, w io.Writer) error
- func UninstallLoginAgent() error
- func ValueOK(value string, expect []int) bool
- func WithCompose(ctx context.Context, c *composeclient.Client) context.Context
- type Action
- type Decision
- type ExitRecord
- type LaunchState
- type LaunchStatus
- type LogFile
- type LoginAgent
- type Report
- type Shape
Constants ¶
const ( LaunchKindWidth = 10 LaunchNameWidth = 18 LaunchStatusWidth = 24 LaunchCommandWidth = 40 )
const AgentLabel = "com.tscatalog.autostart"
AgentLabel is the launchd label for the one-shot login hook.
Variables ¶
This section is empty.
Functions ¶
func AutostartLogPath ¶
AutostartLogPath is stdout/stderr for the login hook, not for service processes.
func CatalogOwns ¶
CatalogOwns reports whether this catalog can stop the service. A process counts while its pidfile is still the process we started. An external helper counts when it has a stop argv. A compose project always counts. Anything else listening on the port is not ours.
func DialCompose ¶
DialCompose opens one client when a selected service is compose. It returns (nil, nil) when none are. A dial failure is returned to the caller.
func FollowFile ¶
FollowFile seeks to the end of path and copies new bytes to w every 200ms. It returns nil when ctx is done. A missing file is an error before the loop.
func FollowStreams ¶
FollowStreams runs external argv and compose log streams until ctx is done. Process files are not included; the caller polls those.
func FormatLaunchTable ¶
func FormatLaunchTable(rows []LaunchStatus) string
FormatLaunchTable renders process, container, and external rows for describe views.
func FormatPS ¶
func FormatPS(rows []LaunchStatus) string
FormatPS renders the ps table. Empty id and shape print as "-". PID 0 prints as "-".
func InstallLoginAgent ¶
func InstallLoginAgent(LoginAgent) error
InstallLoginAgent is only implemented on macOS.
func LocalHealthy ¶
LocalHealthy reports whether the process is accepting the catalog's local check. Public HTTPS and host approval are ignored.
func Logs ¶
func Logs(ctx context.Context, s catalog.Service, which string, tail int, follow, tailSet bool, w io.Writer, comp *composeclient.Client) error
Logs writes the selected rows to w. which is the ps NAME. Empty which follows every row of the service. tailSet is true when the user passed --tail; external argv ignores it.
func NeedsCompose ¶
NeedsCompose reports whether any spec resolves to compose.
func ReadTail ¶
ReadTail returns the last n lines of path. n < 0 returns every line. n == 0 returns an empty slice. A missing file is "no log file".
func Reap ¶
Reap is the parent of a detached process. tscatalog exits after up, so this copy of the binary (re-exec'd with __reap) is what waits and records the exit.
func Restart ¶
Restart starts name when nothing is listening. When the port is open, it stops that service first, and only if this catalog owns the process. requires are started locally and are not published. Stop never follows requires.
func UninstallLoginAgent ¶
func UninstallLoginAgent() error
UninstallLoginAgent is only implemented on macOS.
func ValueOK ¶
ValueOK reports whether a probe cell is success. "tcp" is success. With an empty expect list, HTTP 2xx and 3xx are success.
func WithCompose ¶
WithCompose attaches a client opened once for an up, stop, or restart.
Types ¶
type Decision ¶
type Decision struct {
Action Action
// Note explains ActionNone. Empty when a restart will run.
Note string
}
Decision is whether restarting the process can fix a row.
type ExitRecord ¶
type ExitRecord struct {
State string `json:"state"`
Code int `json:"code,omitempty"`
Signal string `json:"signal,omitempty"`
At time.Time `json:"at"`
}
ExitRecord is what the reaper writes when a process slot ends. State is exited, signaled, or stopped.
type LaunchState ¶
type LaunchState string
LaunchState is the state column of one ps row.
const ( LaunchRunning LaunchState = "running" LaunchExited LaunchState = "exited" LaunchSignaled LaunchState = "signaled" LaunchStopped LaunchState = "stopped" LaunchGone LaunchState = "gone" LaunchUnwatched LaunchState = "unwatched" )
type LaunchStatus ¶
type LaunchStatus struct {
Service string
ID string
Index int
Shape Shape
State LaunchState
PID int
Detail string
// Command is the running argv for a process or container row.
Command string
}
LaunchStatus is one ps row.
func LaunchStatuses ¶
func LaunchStatuses(ctx context.Context, s catalog.Service, comp *composeclient.Client, dialErr error) []LaunchStatus
LaunchStatuses reports one row per process, one row per container, or one row for an external helper. A compose dial failure is a single gone row; it does not fail the caller. comp and dialErr are ignored for a service that has no compose spec.
func (LaunchStatus) DescribeParts ¶
func (st LaunchStatus) DescribeParts() (key, status, command string)
DescribeParts is the describe/cat9s field for one row. The key is process, container, or external. Command is set only while running.
func (LaunchStatus) TableParts ¶
func (st LaunchStatus) TableParts() (kind, name, status, command string)
TableParts is one launch row for the describe table.
type LogFile ¶
LogFile is a process log the cat9s view can poll.
func CaptureLogs ¶
func CaptureLogs(ctx context.Context, s catalog.Service, which string, comp *composeclient.Client) (lines []string, files []LogFile, stream bool, err error)
CaptureLogs is the non-following read used by cat9s. stream is true when a later follow should start an external argv or compose Logs.
type LoginAgent ¶
LoginAgent is the macOS login hook. It is not the parent of catalog processes.
func (LoginAgent) Plist ¶
func (a LoginAgent) Plist() ([]byte, error)
Plist is a RunAtLoad agent with no KeepAlive. stop of a child stays down until the next autostart, up, restart, or a new login session.