fix: Offense-Cleanup-Worker mit niedrigster CPU/IO-Priorität ausführen

This commit is contained in:
2026-04-16 21:33:47 +02:00
parent 2559ed89ea
commit ccdc555246
5 changed files with 19 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
#
# Autor: Patrick Asmus
# E-Mail: support@techniverse.net
# Datum: 2026-04-14
# Datum: 2026-04-16
# Lizenz: MIT
###############################################################################
@@ -25,6 +25,12 @@ fi
# shellcheck source=adguard-shield.conf
source "$CONFIG_FILE"
# ─── Niedrigste Priorität setzen (CPU + I/O) ─────────────────────────────────
# Stellt sicher, dass der Worker auch bei manuellem Start nie andere Dienste
# verdrängt. nice 19 = niedrigste CPU-Priorität, ionice idle = nur bei freier I/O.
renice -n 19 $$ >/dev/null 2>&1 || true
ionice -c 3 -p $$ >/dev/null 2>&1 || true
# ─── Worker PID-File ──────────────────────────────────────────────────────────
WORKER_PID_FILE="/var/run/adguard-offense-cleanup-worker.pid"
@@ -80,6 +86,7 @@ cleanup_expired_offenses() {
now=$(date '+%s')
local cleaned=0
local batch_count=0
for offense_file in "${STATE_DIR}"/*.offenses; do
[[ -f "$offense_file" ]] || continue
@@ -101,6 +108,12 @@ cleanup_expired_offenses() {
rm -f "$offense_file"
cleaned=$((cleaned + 1))
fi
# Alle 10 Dateien kurz pausieren, um I/O-Bursts zu vermeiden
batch_count=$((batch_count + 1))
if (( batch_count % 10 == 0 )); then
sleep 0.1
fi
done
if [[ $cleaned -gt 0 ]]; then