| Server IP : 85.155.190.233 / Your IP : 216.73.216.103 Web Server : nginx/1.24.0 System : Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 User : wp-moonbloom ( 1001) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /opt/Gemini_Swarm_Core/ |
Upload File : |
import sys
import os
sys.path.insert(0, 'Gemini_Swarm_Core/scripts')
from _ssh import connect, run_cmd, safe_print
def cleanup_sessions():
try:
client = connect()
except Exception as e:
safe_print(f"Connection failed: {e}")
return
safe_print("Checking for abandoned sessions...")
# List sessions, look for ones without active TTY or in closing state
_, out, _ = run_cmd(client, "loginctl list-sessions --no-legend")
session_ids = [line.split()[0] for line in out.strip().split('\n') if line.strip()]
if not session_ids:
safe_print("No sessions found.")
else:
for sid in session_ids:
safe_print(f"Terminating session {sid}...")
run_cmd(client, f"loginctl terminate-session {sid}")
safe_print("Optimizing systemd-logind config...")
# Set KillUserProcesses=yes and shorter timeouts
config_cmd = (
"sed -i 's/#KillUserProcesses=no/KillUserProcesses=yes/' /etc/systemd/logind.conf && "
"systemctl restart systemd-logind"
)
code, out, err = run_cmd(client, config_cmd)
if code == 0:
safe_print("Cleanup and optimization complete. System will now auto-kill lingering processes.")
else:
safe_print(f"Optimization failed: {err}")
client.close()
if __name__ == "__main__":
cleanup_sessions()