feat: add log rotation configuration for native runners on macOS
This commit is contained in:
@@ -401,6 +401,19 @@ add_native_runner() {
|
||||
cp "$tmpfile" "$plist_path"
|
||||
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
|
||||
launchctl load "$plist_path"
|
||||
log_success "Native runner '${RUNNER_NAME}' loaded via launchd"
|
||||
@@ -443,6 +456,13 @@ remove_native_runner() {
|
||||
log_success "Plist removed: $plist_path"
|
||||
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
|
||||
printf 'Remove runner data at %s? [y/N] ' "${RUNNER_DATA_PATH}"
|
||||
read -r confirm
|
||||
|
||||
Reference in New Issue
Block a user