Documentation
¶
Overview ¶
background.go provides RunBackground, which re-spawns the current binary as a detached background process running "start --foreground". The parent returns immediately with the child's PID. Platform-specific process detachment (new session on Unix, DETACHED_PROCESS on Windows) is handled by setSysProcAttr defined in background_unix.go / background_windows.go.
Package daemon implements the main OpenCron daemon that orchestrates cron job scheduling, file system watching for hot-reload, and the Telegram bot. The Daemon struct wraps robfig/cron with SkipIfStillRunning to prevent overlapping job execution, manages job registration and atomic hot-reload, maintains a PID file for single-instance enforcement, opens the SQLite database, and handles graceful shutdown on SIGINT/SIGTERM.
service.go provides a system service wrapper using kardianos/service for running the OpenCron daemon as a Windows Service or systemd unit. It implements the service.Interface (Start/Stop) and exposes InstallService and UninstallService functions for managing the service lifecycle.
watcher.go implements a file system watcher using fsnotify for hot-reloading job configurations. It monitors the schedules directory for Write, Create, and Remove events on YAML files, debounces changes for 500ms, and triggers Daemon.Reload to re-register all jobs atomically. Stop uses sync.Once to prevent double-close panics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallService ¶
func InstallService() error
InstallService installs OpenCron as a system service.
func RunBackground ¶
RunBackground re-launches the current binary with "start --foreground" as a detached child process and returns its PID. The caller should exit or return so the terminal is freed; the child continues running independently.
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon manages the cron job lifecycle.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches the schedules directory for changes and triggers hot-reload.
func NewWatcher ¶
NewWatcher creates a file watcher for the schedules directory.