Files
ALL-teach_sys/start-industry.bat

248 lines
6.2 KiB
Batchfile
Raw Normal View History

@echo off
chcp 65001 >nul 2>&1
setlocal enabledelayedexpansion
:: ========================================
:: Education System - Windows Startup Script
:: ========================================
:MAIN_MENU
cls
echo ========================================
echo Education System - Smart Launcher
echo ========================================
echo.
echo Select an option:
echo.
echo 0 - Start All Industries
echo --------------
echo 1 - Cultural Tourism (Port: 5150)
echo 2 - Smart Manufacturing (Port: 5151)
echo 3 - Smart Development (Port: 5152)
echo 4 - Finance and Commerce (Port: 5153)
echo 5 - Visual Design (Port: 5154)
echo 6 - Transportation and Logistics (Port: 5155)
echo 7 - Healthcare (Port: 5156)
echo 8 - Civil and Water Engineering (Port: 5157)
echo 9 - Food Industry (Port: 5158)
echo 10 - Chemical Industry (Port: 5159)
echo 11 - Energy Industry (Port: 5160)
echo 12 - Environmental Protection (Port: 5161)
echo --------------
echo A - Stop All Industries
echo S - Check Status
echo Q - Exit
echo.
set /p choice=Enter your choice:
if "%choice%"=="0" goto START_ALL
if "%choice%"=="1" goto START_1
if "%choice%"=="2" goto START_2
if "%choice%"=="3" goto START_3
if "%choice%"=="4" goto START_4
if "%choice%"=="5" goto START_5
if "%choice%"=="6" goto START_6
if "%choice%"=="7" goto START_7
if "%choice%"=="8" goto START_8
if "%choice%"=="9" goto START_9
if "%choice%"=="10" goto START_10
if "%choice%"=="11" goto START_11
if "%choice%"=="12" goto START_12
if /i "%choice%"=="A" goto STOP_ALL
if /i "%choice%"=="S" goto CHECK_STATUS
if /i "%choice%"=="Q" goto EXIT
echo Invalid option!
timeout /t 2 >nul
goto MAIN_MENU
:START_ALL
echo.
echo Starting all industries...
call :START_INDUSTRY "frontend" "Cultural Tourism" 5150
call :START_INDUSTRY "frontend_智能制造" "Smart Manufacturing" 5151
call :START_INDUSTRY "frontend_智能开发" "Smart Development" 5152
call :START_INDUSTRY "frontend_财经商贸" "Finance Commerce" 5153
call :START_INDUSTRY "frontend_视觉设计" "Visual Design" 5154
call :START_INDUSTRY "frontend_交通物流" "Transportation" 5155
call :START_INDUSTRY "frontend_大健康" "Healthcare" 5156
call :START_INDUSTRY "frontend_土木水利" "Civil Engineering" 5157
call :START_INDUSTRY "frontend_食品" "Food Industry" 5158
call :START_INDUSTRY "frontend_化工" "Chemical Industry" 5159
call :START_INDUSTRY "frontend_能源" "Energy Industry" 5160
call :START_INDUSTRY "frontend_环保" "Environmental" 5161
echo.
echo All industries started!
pause
goto MAIN_MENU
:START_1
call :START_INDUSTRY "frontend" "Cultural Tourism" 5150
pause
goto MAIN_MENU
:START_2
call :START_INDUSTRY "frontend_智能制造" "Smart Manufacturing" 5151
pause
goto MAIN_MENU
:START_3
call :START_INDUSTRY "frontend_智能开发" "Smart Development" 5152
pause
goto MAIN_MENU
:START_4
call :START_INDUSTRY "frontend_财经商贸" "Finance Commerce" 5153
pause
goto MAIN_MENU
:START_5
call :START_INDUSTRY "frontend_视觉设计" "Visual Design" 5154
pause
goto MAIN_MENU
:START_6
call :START_INDUSTRY "frontend_交通物流" "Transportation" 5155
pause
goto MAIN_MENU
:START_7
call :START_INDUSTRY "frontend_大健康" "Healthcare" 5156
pause
goto MAIN_MENU
:START_8
call :START_INDUSTRY "frontend_土木水利" "Civil Engineering" 5157
pause
goto MAIN_MENU
:START_9
call :START_INDUSTRY "frontend_食品" "Food Industry" 5158
pause
goto MAIN_MENU
:START_10
call :START_INDUSTRY "frontend_化工" "Chemical Industry" 5159
pause
goto MAIN_MENU
:START_11
call :START_INDUSTRY "frontend_能源" "Energy Industry" 5160
pause
goto MAIN_MENU
:START_12
call :START_INDUSTRY "frontend_环保" "Environmental" 5161
pause
goto MAIN_MENU
:START_INDUSTRY
set "dir=%~1"
set "name=%~2"
set "port=%~3"
echo.
echo ========================================
echo Starting %name% (Port: %port%)
echo ========================================
if not exist "%dir%" (
echo [ERROR] Directory %dir% does not exist!
exit /b 1
)
netstat -an | findstr ":%port%" >nul 2>&1
if %errorlevel%==0 (
echo [WARNING] Port %port% is already in use
set /p stop_choice=Stop existing service and restart? (y/n):
if /i "!stop_choice!"=="y" (
echo Stopping service on port %port%...
for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":%port%"') do (
taskkill /F /PID %%a >nul 2>&1
)
timeout /t 2 >nul
) else (
echo Skipping %name%
exit /b 1
)
)
cd "%dir%" 2>nul
if not exist "node_modules" (
echo [INFO] Dependencies not found, installing...
echo This may take 1-3 minutes, please wait...
call npm install
if !errorlevel! neq 0 (
echo [ERROR] Failed to install dependencies for %name%!
cd ..
exit /b 1
)
echo [SUCCESS] Dependencies installed for %name%!
) else (
echo [INFO] Dependencies already exist for %name%
)
echo [INFO] Starting %name%...
start /min cmd /c "npm run dev"
cd ..
timeout /t 3 >nul
netstat -an | findstr ":%port%" >nul 2>&1
if %errorlevel%==0 (
echo [SUCCESS] %name% started successfully!
echo Access URL: http://localhost:%port%
) else (
echo [ERROR] Failed to start %name%!
exit /b 1
)
exit /b 0
:STOP_ALL
echo.
echo Stopping all industry services...
taskkill /F /IM node.exe >nul 2>&1
if %errorlevel%==0 (
echo All services stopped successfully!
) else (
echo No running services found.
)
pause
goto MAIN_MENU
:CHECK_STATUS
cls
echo ========================================
echo Industry Running Status
echo ========================================
echo.
call :CHECK_PORT 5150 "Cultural Tourism"
call :CHECK_PORT 5151 "Smart Manufacturing"
call :CHECK_PORT 5152 "Smart Development"
call :CHECK_PORT 5153 "Finance Commerce"
call :CHECK_PORT 5154 "Visual Design"
call :CHECK_PORT 5155 "Transportation"
call :CHECK_PORT 5156 "Healthcare"
call :CHECK_PORT 5157 "Civil Engineering"
call :CHECK_PORT 5158 "Food Industry"
call :CHECK_PORT 5159 "Chemical Industry"
call :CHECK_PORT 5160 "Energy Industry"
call :CHECK_PORT 5161 "Environmental"
echo.
pause
goto MAIN_MENU
:CHECK_PORT
netstat -an | findstr ":%1" >nul 2>&1
if %errorlevel%==0 (
echo [RUNNING] %~2 - Port: %1 - http://localhost:%1
) else (
echo [STOPPED] %~2 - Port: %1
)
exit /b 0
:EXIT
echo Goodbye!
exit