@echo off REM Windows开发环境启动脚本 REM 设置端口 set PORT=5000 if not defined DEPLOY_RUN_PORT set DEPLOY_RUN_PORT=%PORT% REM 检查并清除端口占用 echo Checking port %DEPLOY_RUN_PORT%... netstat -ano | findstr :%DEPLOY_RUN_PORT% | findstr LISTENING >nul if %errorlevel% equ 0 ( echo Port %DEPLOY_RUN_PORT% is in use, attempting to clear... for /f "tokens=5" %%a in ('netstat -ano ^| findstr :%DEPLOY_RUN_PORT% ^| findstr LISTENING') do ( echo Killing process %%a on port %DEPLOY_RUN_PORT% taskkill /PID %%a /F >nul 2>&1 ) timeout /t 2 /nobreak >nul echo Port %DEPLOY_RUN_PORT% cleared. ) else ( echo Port %DEPLOY_RUN_PORT% is free. ) REM 设置工作目录 if not defined COZE_WORKSPACE_PATH set COZE_WORKSPACE_PATH=%cd% echo Starting HTTP service on port %DEPLOY_RUN_PORT% for dev... echo Working directory: %COZE_WORKSPACE_PATH% REM 启动开发服务器 cd /d "%COZE_WORKSPACE_PATH%" set PORT=%DEPLOY_RUN_PORT% pnpm tsx watch src/server.ts