-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_internpath.sh
More file actions
56 lines (49 loc) · 1.84 KB
/
Copy pathstop_internpath.sh
File metadata and controls
56 lines (49 loc) · 1.84 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
#!/usr/bin/env bash
# InternPath - One-Click Stop Script for Linux / Cloud Servers
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_ROOT"
echo "=============================================="
echo " InternPath: Cloud/Linux Stop Script "
echo "=============================================="
# 1. Stop systemd service if present
SERVICE_NAME="internpath"
if systemctl list-unit-files | grep -q "${SERVICE_NAME}.service"; then
echo "[Systemd Service Mode Detected]"
for unit in "${SERVICE_NAME}-advisor-worker" "${SERVICE_NAME}-worker" "${SERVICE_NAME}-ai" "${SERVICE_NAME}"; do
if systemctl list-unit-files | grep -q "${unit}.service"; then
echo "Stopping ${unit} service..."
sudo systemctl stop "${unit}"
fi
done
fi
# 2. Stop manual running background process if PID file exists
stop_pid_file() {
local pid_file="$1"
local label="$2"
if [ ! -f "$pid_file" ]; then
return
fi
PID=$(cat "$pid_file")
if kill -0 $PID 2>/dev/null; then
echo "[Manual Running Process Detected]"
echo "Stopping $label process (PID: $PID)..."
kill $PID
rm "$pid_file"
echo "Process stopped."
else
rm "$pid_file"
fi
}
stop_pid_file "logs/rq-worker.pid" "RQ worker"
stop_pid_file "logs/rq-advisor-worker.pid" "Advisor RQ worker"
stop_pid_file "logs/backend.pid" "FastAPI backend"
stop_pid_file "logs/ai-service.pid" "AI service"
# 3. Stop Docker Compose if active
if [ -f "docker-compose.yml" ] && command -v docker >/dev/null 2>&1 && docker compose ps >/dev/null 2>&1; then
echo "[Docker Mode Detected]"
echo "Stopping Docker containers..."
docker compose down
fi
echo "=============================================="
echo " InternPath stopped successfully!"
echo "=============================================="