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

45 lines
1.6 KiB
Python

#!/usr/bin/env python3
# V88: Fix wevia-auto-heal (raise worker threshold) + wevia-master-autoheal (timings)
# Fix 1: auto-heal threshold
path1 = "/var/www/html/api/wevia-auto-heal.php"
with open(path1, "rb") as f:
raw1 = f.read()
if b"V88" not in raw1:
# Change threshold 50 → 180 (max is 140 total pools = safe headroom)
old = b"$w > 50"
new = b"$w > 180" # V88: raised from 50 to 180 (total max = 140 workers)
if old in raw1:
raw1 = raw1.replace(old, new, 1)
# Also skip the self-kill - instead just log + call FPM reload via systemctl
old_kill = b'shell_exec("killall -9 php-fpm8.5; sleep 2; systemctl start php8.5-fpm &")'
new_kill = b'/* V88: disabled self-kill. Use systemctl reload instead */ shell_exec("sudo -n systemctl reload php8.5-fpm 2>&1 > /tmp/fpm-reload.log &")'
if old_kill in raw1:
raw1 = raw1.replace(old_kill, new_kill, 1)
with open(path1, "wb") as f:
f.write(raw1)
print(f"auto-heal: size={len(raw1)}")
# Fix 2: master-autoheal timings
path2 = "/var/www/html/api/wevia-master-autoheal.php"
with open(path2, "rb") as f:
raw2 = f.read()
if b"V88 hardened" not in raw2:
old = b"<?php"
new = b"""<?php
// V88 hardened: limits to avoid fcgi timeout
@set_time_limit(60);
@ini_set('memory_limit', '256M');
@ini_set('max_execution_time', 60);
"""
if old in raw2 and raw2.count(b"V88 hardened") == 0:
idx = raw2.find(old)
raw2 = raw2[:idx] + new + raw2[idx+len(old):]
with open(path2, "wb") as f:
f.write(raw2)
print(f"master-autoheal: size={len(raw2)}")
print("DONE")