-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.sh
More file actions
31 lines (25 loc) · 753 Bytes
/
Copy pathstop.sh
File metadata and controls
31 lines (25 loc) · 753 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
#!/bin/bash
PID_DIR="pids"
echo "🛑 Stopping all services..."
echo "--------------------------------"
if [ ! -d "$PID_DIR" ]; then
echo "PID directory not found. No services to stop."
exit 0
fi
for pid_file in $PID_DIR/*.pid; do
if [ -f "$pid_file" ]; then
PID=$(cat "$pid_file")
SERVICE_NAME=$(basename "$pid_file" .pid)
# Check if the process is still running
if ps -p $PID > /dev/null; then
echo "Killing $SERVICE_NAME process with PID $PID..."
kill $PID
rm "$pid_file"
else
echo "Process for $SERVICE_NAME (PID $PID) is not running. Cleaning up PID file."
rm "$pid_file"
fi
fi
done
echo "--------------------------------"
echo "✅ All services stopped and PID files cleaned up."