-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_service.sh
More file actions
executable file
·74 lines (62 loc) · 1.96 KB
/
stop_service.sh
File metadata and controls
executable file
·74 lines (62 loc) · 1.96 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
68
69
70
71
72
73
74
#!/bin/bash
# stop_service.sh - Stops dual-node llama servers and nginx
# Simplified to dual-mode only. No mode params. Error handling on ALL functions.
# Uses centralized .env for model configuration. Zero-sudo.
set -e
# Load configuration from .env (centralized model settings)
load_env() {
local env_file="$(dirname "${BASH_SOURCE[0]}")/.env"
if [[ -f "$env_file" ]]; then
set -a
# shellcheck source=.env
source "$env_file"
set +a
fi
}
load_env
# ─────────────────────────────────────────────
# ERROR HANDLING FOR ALL FUNCTIONS
# ─────────────────────────────────────────────
error() {
echo "❌ ERROR: $1" >&2
exit 1
}
success() {
echo "✅ $1"
}
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}
stop_nginx() {
log "🛑 Stopping user-level nginx..."
systemctl --user stop user-nginx 2>/dev/null || log "Nginx was not running"
success "Nginx stopped"
}
stop_nodes() {
log "Stopping dual-node servers (llama-node1 and llama-node2)..."
systemctl --user stop llama-node1 2>/dev/null || log "Node1 already stopped"
systemctl --user stop llama-node2 2>/dev/null || log "Node2 already stopped"
success "Dual nodes stopped"
}
cleanup() {
log "Cleaning up..."
# Optional: remove runtime if desired but not required
success "Cleanup done"
}
show_summary() {
echo ""
echo "✓ All services stopped."
echo "To restart: ./start_service.sh"
echo "To re-register: ./setup-llama.sh"
echo "Model config (${MODEL_NAME:-Unknown}, alias: coder, ctx: ${CONTEXT_LENGTH:-200000}) is ready for next start."
}
# Main
main() {
log "Stopping dual-mode LLM serving system (${MODEL_NAME:-Unknown})..."
stop_nginx
stop_nodes
cleanup
show_summary
success "Stop operation completed."
}
main "$@"