-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathstop_server.sh
More file actions
executable file
·39 lines (30 loc) · 911 Bytes
/
stop_server.sh
File metadata and controls
executable file
·39 lines (30 loc) · 911 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
32
33
34
35
36
37
38
39
#!/bin/bash
# Stop the Django development server
echo "Looking for Django server processes..."
# Find Django server processes
PIDS=$(ps aux | grep "manage.py runserver" | grep -v grep | awk '{print $2}')
if [ -z "$PIDS" ]; then
echo "No Django server processes found."
exit 0
fi
echo "Found Django server process(es): $PIDS"
echo "Stopping server..."
# Kill the processes
for PID in $PIDS; do
kill $PID
echo "Sent SIGTERM to process $PID"
done
# Wait a moment and check if they're gone
sleep 2
# Check if any are still running
REMAINING=$(ps aux | grep "manage.py runserver" | grep -v grep | awk '{print $2}')
if [ -z "$REMAINING" ]; then
echo "Server stopped successfully."
else
echo "Some processes still running, forcing kill..."
for PID in $REMAINING; do
kill -9 $PID
echo "Sent SIGKILL to process $PID"
done
echo "Server forcefully stopped."
fi