| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #!/bin/sh
- # 颜色定义
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- YELLOW='\033[0;33m'
- NC='\033[0m' # No Color
- # 默认环境配置
- DEFAULT_PROFILE="prod"
- # 使用说明
- usage() {
- echo -e "${GREEN}Usage: sh run.sh [module] [profile]"
- echo -e "示例:"
- echo -e " sh run.sh system # 启动系统模块(默认 ${DEFAULT_PROFILE} 环境)"
- echo -e " sh run.sh gateway dev # 启动网关模块(dev 环境)"
- echo -e " sh run.sh stopAll # 停止所有服务${NC}"
- echo -e "\n${YELLOW}可用模块:${NC}"
- echo " gateway - API网关"
- echo " auth - 认证中心"
- echo " system - 系统模块"
- echo " job - 系统模块"
- echo " file - 文件服务"
- echo " gen - 代码生成服务"
- echo " monitor - 监控中心"
- echo " exam - 考试服务"
- echo " airportWeb - 管理前端"
- echo " app - 移动端"
- echo -e "\n${YELLOW}管理命令:${NC}"
- echo " stopAll - 停止所有服务"
- echo " rmAll - 删除所有容器"
- echo " restart [module] [profile] - 重启指定模块"
- exit 1
- }
- # 网关模块
- gateway() {
- restart_service "ruoyi-gateway" "$1" "网关服务"
- }
- # 认证中心
- auth() {
- restart_service "ruoyi-auth" "$1" "认证中心"
- }
- # 系统模块
- system() {
- restart_service "ruoyi-modules-system" "$1" "系统模块"
- }
- # 定时任务
- job() {
- restart_service "ruoyi-modules-job" "$1" "定时任务"
- }
- # 文件服务
- file() {
- restart_service "ruoyi-modules-file" "$1" "文件服务"
- }
- # 文件服务
- gen() {
- restart_service "ruoyi-modules-gen" "$1" "代码生成服务"
- }
- # 监控中心
- monitor() {
- restart_service "ruoyi-visual-monitor" "$1" "监控中心"
- }
- # 考试服务
- exam() {
- restart_service "airport-exam" "$1" "考试服务"
- }
- # 管理前端
- airportWeb() {
- restart_service "airport-web" "$1" "管理前端"
- }
- # 移动端
- app() {
- restart_service "airport-app" "$1" "移动端"
- }
- # 核心重启逻辑
- restart_service() {
- local service=$1
- local profile=${2:-$DEFAULT_PROFILE}
- local service_name=$3
- echo -e "${YELLOW}>>> 重启 ${service_name} ${service} [环境: ${profile}]...${NC}"
- docker-compose stop $service
- docker-compose rm -f $service
- docker-compose build $service
- # 传递环境变量
- export PROFILE=$profile
- docker-compose up -d $service
- echo -e "${GREEN}✓ ${service_name} 启动完成${NC}"
- echo -e "环境: ${YELLOW}${profile}${NC} | 容器状态:"
- docker-compose ps | grep $service
- }
- # 停止所有服务
- stopAll() {
- echo -e "${RED}>>> 停止所有服务...${NC}"
- docker-compose stop
- }
- # 删除所有容器
- rmAll() {
- echo -e "${RED}>>> 删除所有容器...${NC}"
- docker-compose rm -f
- }
- # 重启指定模块
- restart() {
- case "$1" in
- "gateway") gateway "$2" ;;
- "auth") auth "$2" ;;
- "system") system "$2" ;;
- "job") job "$2" ;;
- "file") file "$2" ;;
- "gen") gen "$2" ;;
- "monitor") monitor "$2" ;;
- "exam") exam "$2" ;;
- "airportWeb") airportWeb "$2" ;;
- "app") app "$2" ;;
- *) echo -e "${RED}未知模块: $1${NC}"; usage ;;
- esac
- }
- # 主逻辑
- case "$1" in
- "gateway") gateway "$2" ;;
- "auth") auth "$2" ;;
- "system") system "$2" ;;
- "job") job "$2" ;;
- "file") file "$2" ;;
- "gen") gen "$2" ;;
- "exam") exam "$2" ;;
- "monitor") monitor "$2" ;;
- "airportWeb") airportWeb "$2" ;;
- "app") app "$2" ;;
- "stopAll") stopAll ;;
- "rmAll") rmAll ;;
- "restart") restart "$2" "$3" ;;
- *) usage ;;
- esac
|