Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FollowLogs ¶
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.
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 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.