Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Daemonize ¶
Daemonize detaches the process from the terminal and runs it in the background by re-executing the current command as a detached child (session leader on Unix, detached process on Windows) and exiting the parent.
Callers that want to know whether the child actually came up should use Spawn instead and keep the parent alive until it has.
overrideArgs pins flags the parent resolved (e.g. "--port", "9000") so the detached child binds exactly what the parent decided instead of re-resolving its own command line. See buildDaemonArgs.
func IsDaemonProcess ¶
func IsDaemonProcess() bool
IsDaemonProcess checks if the current process is running as a daemon
func NewLogger ¶
func NewLogger(cfg *LogRotationConfig) *lumberjack.Logger
NewLogger creates a new lumberjack logger with the given configuration
func Spawn ¶ added in v1.261116.0
Spawn re-executes the current command as a detached daemon child and returns without exiting the parent. The returned channel yields the child's exit status (nil for a clean exit) once it ends, so the parent can tell a child that came up from one that died on startup. The child outlives the parent: it is its own session leader and its stdio is detached.
Types ¶
type LogRotationConfig ¶
type LogRotationConfig struct {
Filename string // Log file path
MaxSize int // Maximum size in megabytes
MaxBackups int // Maximum number of old log files to retain
MaxAge int // Maximum number of days to retain old log files
Compress bool // Compress old log files
}
LogRotationConfig holds configuration for log rotation
func DefaultLogRotationConfig ¶
func DefaultLogRotationConfig(logFile string) *LogRotationConfig
DefaultLogRotationConfig returns default log rotation settings