-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-woofplot.sh
More file actions
executable file
·67 lines (53 loc) · 1.48 KB
/
Copy pathstop-woofplot.sh
File metadata and controls
executable file
·67 lines (53 loc) · 1.48 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
WOOFPLOT_DIR="/home/ubuntu/woofplot"
RQ="$WOOFPLOT_DIR/woofplotenv/bin/rq"
echo "Stopping woofplot..."
#
# Stop RQ workers cleanly.
#
echo "Stopping RQ workers..."
# SIGTERM asks RQ workers to shut down gracefully.
# Match only workers launched from this woofplot virtualenv.
PIDS=$(pgrep -f "$WOOFPLOT_DIR/woofplotenv/bin/rq worker")
if [ -n "$PIDS" ]; then
echo "RQ worker PIDs: $PIDS"
kill -TERM $PIDS
# Give workers a few seconds to exit.
for i in {1..10}; do
if ! pgrep -f "$WOOFPLOT_DIR/woofplotenv/bin/rq worker" >/dev/null; then
break
fi
sleep 1
done
# Kill anything that did not stop.
PIDS=$(pgrep -f "$WOOFPLOT_DIR/woofplotenv/bin/rq worker")
if [ -n "$PIDS" ]; then
echo "Forcing remaining RQ workers to stop: $PIDS"
kill -KILL $PIDS
fi
else
echo "No RQ workers running."
fi
#
# Stop woofplot Flask/backend server.
#
echo "Stopping woofplot server..."
PIDS=$(pgrep -f "python.*woofplot-server.py")
if [ -n "$PIDS" ]; then
echo "Server PIDs: $PIDS"
kill -TERM $PIDS
sleep 2
PIDS=$(pgrep -f "python.*woofplot-server.py")
if [ -n "$PIDS" ]; then
echo "Forcing remaining server processes to stop: $PIDS"
kill -KILL $PIDS
fi
else
echo "No woofplot server running."
fi
echo
echo "Remaining woofplot processes:"
pgrep -af "woofplot.*(rq worker|woofplot-server)" || true
echo
echo "Woofplot stopped."
echo "Redis and PostgreSQL were left running."