-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.py
More file actions
executable file
·31 lines (24 loc) · 799 Bytes
/
stop.py
File metadata and controls
executable file
·31 lines (24 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import os
import signal
from pathlib import Path
def stop_server():
pid_file = Path("helpful-tools-v2.pid")
if not pid_file.exists():
print("❌ Server is not running (no PID file found)")
return
try:
with open(pid_file, "r") as f:
pid = int(f.read().strip())
# Send termination signal
os.kill(pid, signal.SIGTERM)
print(f"⏹️ Server stopped (PID: {pid})")
# Clean up PID file
pid_file.unlink()
except ProcessLookupError:
print("❌ Server process not found")
pid_file.unlink() # Clean up stale PID file
except Exception as e:
print(f"❌ Error stopping server: {e}")
if __name__ == "__main__":
stop_server()