-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·50 lines (42 loc) · 1.08 KB
/
stop.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.08 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Function to log messages
log_message() {
echo "$1"
}
# Function to read PID from server_pids
get_pid() {
local server=$1
local pid=$(grep "^$server:" ./server_pids | cut -d':' -f2)
echo $pid
}
# Stop a server by PID
stop_server() {
local server=$1
local pid=$(get_pid $server)
if [ ! -z "$pid" ]; then
log_message "Stopping $server server (PID: $pid)..."
if kill -9 $pid 2>/dev/null; then
log_message "$server server stopped successfully."
else
log_message "$server server was not running (PID $pid not found)."
fi
else
log_message "No PID found for $server server."
fi
}
# Main function
main() {
# Check if PID file exists
if [ ! -f "./server_pids" ]; then
log_message "Error: server_pids not found!"
exit 1
fi
# Stop each server
stop_server "php"
stop_server "vite"
stop_server "eternaltwin"
log_message "Project stopped successfully."
log_message "To start the servers again, run make start."
}
# Run the main function
main