-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_worker.sh
More file actions
44 lines (35 loc) · 1.02 KB
/
stop_worker.sh
File metadata and controls
44 lines (35 loc) · 1.02 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
#!/bin/bash
# Stop PDF Docling Worker
PID_FILE="$(pwd)/worker.pid"
echo "🛑 Stopping PDF Docling Worker"
echo "==============================="
if [[ ! -f "$PID_FILE" ]]; then
echo "❌ No PID file found. Worker may not be running."
echo "Check with: ps aux | grep docling"
exit 1
fi
WORKER_PID=$(cat "$PID_FILE")
if kill -0 "$WORKER_PID" 2>/dev/null; then
echo "📋 Stopping worker with PID $WORKER_PID..."
kill "$WORKER_PID"
# Wait for graceful shutdown
sleep 2
# Force kill if still running
if kill -0 "$WORKER_PID" 2>/dev/null; then
echo "🔨 Force killing worker..."
kill -9 "$WORKER_PID"
sleep 1
fi
# Verify it's stopped
if kill -0 "$WORKER_PID" 2>/dev/null; then
echo "❌ Failed to stop worker"
exit 1
else
echo "✅ Worker stopped successfully"
rm -f "$PID_FILE"
fi
else
echo "⚠️ Worker with PID $WORKER_PID is not running"
echo "🧹 Cleaning up stale PID file"
rm -f "$PID_FILE"
fi