Files
weval-l99/fix_fpm_dedup.py
2026-04-20 14:13:48 +02:00

30 lines
826 B
Python

#!/usr/bin/env python3
path = "/etc/php/8.5/fpm/pool.d/www.conf"
with open(path, "rb") as f:
raw = f.read()
# Keep only first active pm.max_children = 80 line, remove others
# Scan for lines starting with "pm.max_children = 80"
lines = raw.split(b'\n')
kept = []
seen_mc = False
kept_count = 0
removed = 0
for line in lines:
stripped = line.strip()
# Only count ACTIVE lines (not comments)
if stripped.startswith(b"pm.max_children = 80") and not stripped.startswith(b";"):
if seen_mc:
# Skip dupe
removed += 1
continue
seen_mc = True
kept_count += 1
kept.append(line)
new_raw = b'\n'.join(kept)
with open(path, "wb") as f:
f.write(new_raw)
print(f"dedup: {kept_count} kept, {removed} removed")
print(f"size: {len(raw)}{len(new_raw)}")