Files
django-vue3-admin/scripts/stop-celery.sh
T
lewis_yan f6313a93ce feat: add cross-platform service management scripts
Add comprehensive scripts for managing PIS project services:
- start-backend.ps1/.sh: Start Django backend with uvicorn/gunicorn
- start-frontend.ps1/.sh: Start Vue frontend dev server
- start-celery.ps1/.sh: Start Celery worker and beat
- stop-all.ps1/.sh: Stop all services gracefully
- stop-celery.ps1/.sh: Stop Celery services only
- view-logs.ps1/.sh: View and tail log files
- check-status.ps1/.sh: Check service status and ports

Cross-platform support:
- Windows PowerShell scripts with English output (UTF-8 safe)
- Unix/Linux/macOS Bash scripts with Chinese output
- WMI queries for PowerShell 5.1 compatibility
- Unified Makefile and make.ps1 orchestrators

Also add scripts-documentation.md with comprehensive usage guide.
2026-04-01 19:11:45 +08:00

37 lines
986 B
Bash

#!/bin/bash
# ============================================================
# Stop Celery Services
# 使用方法: ./stop-celery.sh
# ============================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
PID_DIR="$PROJECT_ROOT/.pids"
stop_celery() {
local name=$1
local pid_file="$PID_DIR/$name.pid"
local pattern="$2"
if [ -f "$pid_file" ]; then
local pid=$(cat "$pid_file")
if kill -0 "$pid" 2>/dev/null; then
echo "[$name] 停止 (PID: $pid)..."
kill "$pid" 2>/dev/null || true
sleep 1
if kill -0 "$pid" 2>/dev/null; then
kill -9 "$pid" 2>/dev/null || true
fi
fi
rm -f "$pid_file"
fi
# 清理残留
pkill -f "celery.*$pattern" 2>/dev/null || true
}
stop_celery "celery_worker" "worker"
stop_celery "celery_beat" "beat"
echo "[完成] Celery 已停止"