Files
weval-l99/fix_fpm_dedup_all.py
2026-04-20 14:29:18 +02:00

28 lines
739 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()
# Dedup all active pm.* lines
keywords = [b"pm.start_servers", b"pm.min_spare_servers", b"pm.max_spare_servers", b"pm.max_children"]
lines = raw.split(b'\n')
seen = {}
kept = []
for line in lines:
stripped = line.strip()
matched = None
for kw in keywords:
if stripped.startswith(kw + b" ") and not stripped.startswith(b";"):
matched = kw
break
if matched:
if matched in seen:
continue
seen[matched] = True
kept.append(line)
new_raw = b'\n'.join(kept)
with open(path, "wb") as f:
f.write(new_raw)
print(f"size: {len(raw)} -> {len(new_raw)}")