stop-backend.sh 758 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # 后端服务停止脚本
  3. RED='\033[0;31m'
  4. GREEN='\033[0;32m'
  5. YELLOW='\033[1;33m'
  6. NC='\033[0m'
  7. echo -e "${YELLOW}停止后端服务...${NC}"
  8. stop_service() {
  9. local service=$1
  10. local pidfile="logs/${service}.pid"
  11. if [ -f "$pidfile" ]; then
  12. pid=$(cat "$pidfile")
  13. if ps -p $pid > /dev/null 2>&1; then
  14. echo "停止 ${service} (PID: ${pid})"
  15. kill $pid
  16. rm "$pidfile"
  17. else
  18. echo "${service} 未运行"
  19. rm "$pidfile"
  20. fi
  21. else
  22. echo "${service} PID 文件不存在"
  23. fi
  24. }
  25. # 停止所有服务
  26. stop_service apigateway
  27. stop_service glance
  28. stop_service region
  29. stop_service keystone
  30. echo -e "${GREEN}✓ 后端服务已停止${NC}"