From 7ff4624e67a6452f77d330c84b2ce6aee900b638 Mon Sep 17 00:00:00 2001 From: auric Date: Sun, 22 Feb 2026 22:11:01 -0600 Subject: log_tail: add log_dir + log_pattern directory-watch mode Valve games (TF2, GMod) rotate into a new timestamped log file on every map change. The existing fixed-path inotify watch goes stale after the first rotation. This adds a directory-watch mode that auto-switches to the newest matching file whenever one appears. New YAML fields (mutually exclusive with logs:): log_dir: directory to watch for new log files log_pattern: fnmatch(3) glob for filenames; default "*" Changes: - umbrella.h: add log_dir[MAX_PATH] and log_dir_pattern[MAX_PATH] to Unit - log_tail.c: extend LogWatch with dir_wd/dir_path/pattern fields; add log_tail_drain, log_tail_scan_dir, log_tail_switch_file, log_tail_open_fixed_watch, log_tail_open_dir_watch, log_tail_reopen_fixed, log_tail_handle_rotation_dir; refactor log_tail_init, log_tail_handle, log_tail_cleanup - unit.c: parse log_dir and log_pattern YAML keys; warn and drop logs: if both are set on the same unit - AGENTS.md, README.md: document both log-tail modes Co-Authored-By: Claude Sonnet 4.6 --- README.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 30b5db8..6ffbdb7 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,10 @@ health: logs: - /path/to/logs/current.log # up to 4 paths; symlinks resolved +# OR: watch a directory for new log files (mutually exclusive with logs:) +log_dir: /path/to/logs # directory to watch +log_pattern: "L???????.log" # fnmatch glob; default "*" if omitted + # Optional filter — any executable reading stdin, writing stdout log_filter: /usr/lib/umbrella/filters/source.py @@ -86,19 +90,39 @@ stdout after each write works. Python, shell, compiled binary — anything. ## Log file setup -srcds and most dedicated servers create new log files per session. -Point `logs:` at a stable symlink and update it on each server start: +Two modes are available. They are mutually exclusive per unit. + +### Fixed-path mode (`logs:`) + +Point `logs:` at a stable symlink; umbrella resolves it via `realpath()` +at startup and watches the real inode. ```bash # In your startup script / ExecStartPre: ln -sf /srv/game/logs/L0222000.log /srv/game/logs/current.log -# Then SIGHUP umbrella so it re-resolves the symlink: +# SIGHUP umbrella so it re-resolves the symlink: kill -HUP $(cat /run/umbrella/umbrella.pid) ``` -With `sv_log_onefile 1` (Source engine), the log file is fixed for the +With `sv_log_onefile 1` (Source engine), the log file is stable for the server's lifetime, so the symlink only needs updating on restarts. +### Directory-watch mode (`log_dir` + `log_pattern`) + +Valve games (TF2, GMod) create a new timestamped log file on every map +change (`L0222000.log`, `L0222001.log`, ...). Use `log_dir` so umbrella +auto-switches to the newest matching file without a SIGHUP: + +```yaml +log_dir: /home/gmod/nnn/gmodds/garrysmod/logs +log_pattern: "L???????.log" +``` + +- `log_pattern` uses `fnmatch(3)` shell-style globs (e.g. `L???????.log`) +- Omitting `log_pattern` defaults to `"*"` (match all files) +- `log_dir` and `logs:` cannot be combined; if both appear, `logs:` is + ignored with a warning in the daemon log + ## CLI usage ```bash -- cgit v1.2.3