feat(server): 添加数据库连接测试并优化启动脚本

添加了服务器启动时的数据库连接测试功能,确保数据库可用性
新增 start.bat 和 dev.bat 脚本用于简化开发和生产环境启动
脚本会自动检查端口占用并处理依赖安装
This commit is contained in:
祀梦
2025-12-21 21:55:49 +08:00
parent 352698044b
commit 38b200f9b3
3 changed files with 57 additions and 1 deletions

26
scripts/start.bat Normal file
View File

@@ -0,0 +1,26 @@
@echo off
setlocal enabledelayedexpansion
echo Checking if WebWork is already running...
:: 查找占用 3000 端口的进程 PID
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :3000 ^| findstr LISTENING') do (
set PID=%%a
if not "!PID!"=="" (
echo Port 3000 is already in use by PID !PID!. Killing process...
taskkill /F /PID !PID!
)
)
echo Starting WebWork System...
cd ..\backend
if not exist node_modules (
echo node_modules not found, installing dependencies...
call npm install
)
echo Starting Backend Server...
start http://localhost:3000
npm start