tcm

package
v3.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FollowLogs

func FollowLogs(follower tail.Follower, prt Printer, lines int) error

FollowLogs reads the last `lines` lines from the log file and prints them. It continues to follow the log file, printing new lines as they are added.

func RunWatchdog

func RunWatchdog(opts WatchdogOpts) error

RunWatchdog runs TCM and keeps it running until the watchdog receives SIGINT, SIGTERM, SIGHUP or SIGQUIT, which stop TCM with SIGTERM, or a periodic check fails. It refuses to run while its own pid file names a running process, and kills the TCM it started and returns when the pid file of TCM does. Both pid files are removed before it returns.

func TailLogs

func TailLogs(t tail.Reader, prt Printer, lines int) error

TailLogs reads the last `lines` lines from the log file and prints them.

Types

type LoggerOpts

type LoggerOpts struct {
	// Level used to start TCM application.
	Level string
	// Lines number of tail lines to show in logs.
	Lines int
	// IsFollow indicates whether to monitor the logs.
	IsFollow bool
	// NoColor disables colored output in logs.
	NoColor bool
	// ForceColor forces colored output in logs, even if the output stream does not support it.
	// This is useful for testing purposes.
	ForceColor bool
	// NoFormat indicates whether to disable log formatting.
	NoFormat bool
}

LoggerOpts contains configuration for displaying TCM logs.

type Printer

type Printer interface {
	Print(ctx context.Context, in <-chan string) error
}

Printer is an interface for printing formatted log messages.

func NewLogPrinter

func NewLogPrinter(noFormat, noColor bool, out io.Writer) Printer

NewLogPrinter creates a new log printer with optional formatting and coloring.

type TcmCtx

type TcmCtx struct {
	// Path to the TCM executable file.
	Executable string
	// Flag indicating whether the watchdog is enabled.
	Watchdog bool
	// Log configuration to display TCM logs.
	Log LoggerOpts
}

TcmCtx holds parameters and state for managing the TCM process and its watchdog.

type WatchdogOpts

type WatchdogOpts struct {
	// Executable is the TCM binary. It runs without arguments, in the
	// working directory and the environment of the watchdog.
	Executable string
	// PidFile is the pid file of the watchdog, ChildPidFile the one of TCM.
	PidFile      string
	ChildPidFile string
	// RestartDelay is the pause between an exit of TCM and its next start.
	RestartDelay time.Duration
	// StopTimeout is how long TCM may take to stop after SIGTERM before its
	// process group is killed with SIGKILL.
	StopTimeout time.Duration
	// CheckPeriod is how often Check runs while TCM runs; 0 runs no checks.
	CheckPeriod time.Duration
	// Check is the periodic integrity check. A failure kills TCM and ends
	// the watchdog, which does not start TCM again.
	Check func(ctx context.Context) error
}

WatchdogOpts configure RunWatchdog.

Jump to

Keyboard shortcuts

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