feat: add log rotation configuration for native runners on macOS

This commit is contained in:
S
2026-03-01 08:16:32 -05:00
parent 66febf69bb
commit 924401a387

View File

@@ -401,6 +401,19 @@ add_native_runner() {
cp "$tmpfile" "$plist_path" cp "$tmpfile" "$plist_path"
rm -f "$tmpfile" rm -f "$tmpfile"
# Install newsyslog config for log rotation (daily, 5 archives, 50 MB max each).
# newsyslog is macOS's built-in log rotator — configs in /etc/newsyslog.d/ are
# picked up automatically. Requires sudo for /etc/newsyslog.d/ write access.
local newsyslog_conf="/etc/newsyslog.d/com.gitea.runner.${RUNNER_NAME}.conf"
if [[ ! -f "$newsyslog_conf" ]]; then
tmpfile=$(mktemp)
render_template "${SCRIPT_DIR}/templates/com.gitea.runner.newsyslog.conf.tpl" "$tmpfile" \
"\${RUNNER_NAME} \${RUNNER_DATA_PATH}"
sudo cp "$tmpfile" "$newsyslog_conf"
rm -f "$tmpfile"
log_success "Log rotation installed: $newsyslog_conf"
fi
# Load the launchd service # Load the launchd service
launchctl load "$plist_path" launchctl load "$plist_path"
log_success "Native runner '${RUNNER_NAME}' loaded via launchd" log_success "Native runner '${RUNNER_NAME}' loaded via launchd"
@@ -443,6 +456,13 @@ remove_native_runner() {
log_success "Plist removed: $plist_path" log_success "Plist removed: $plist_path"
fi fi
# Remove newsyslog rotation config
local newsyslog_conf="/etc/newsyslog.d/com.gitea.runner.${RUNNER_NAME}.conf"
if [[ -f "$newsyslog_conf" ]]; then
sudo rm -f "$newsyslog_conf"
log_success "Log rotation config removed: $newsyslog_conf"
fi
if [[ -d "${RUNNER_DATA_PATH}" ]]; then if [[ -d "${RUNNER_DATA_PATH}" ]]; then
printf 'Remove runner data at %s? [y/N] ' "${RUNNER_DATA_PATH}" printf 'Remove runner data at %s? [y/N] ' "${RUNNER_DATA_PATH}"
read -r confirm read -r confirm