44 lines
1.0 KiB
Batchfile
44 lines
1.0 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
cd /d "%~dp0"
|
|
|
|
set PORT=18765
|
|
set OLD_PID=
|
|
|
|
echo ==========================================
|
|
echo 歪马送酒 - 采集看板
|
|
echo ==========================================
|
|
echo.
|
|
|
|
if not exist "web\dist\index.html" (
|
|
echo [警告] 缺少前端构建产物 web\dist
|
|
echo 先在 web 目录执行: npm install ^&^& npm run build
|
|
echo.
|
|
)
|
|
|
|
for /f "tokens=5" %%p in ('netstat -ano ^| findstr /c:":%PORT%" ^| findstr /c:"LISTENING"') do set OLD_PID=%%p
|
|
|
|
if defined OLD_PID (
|
|
echo [提示] 端口 %PORT% 已被 PID !OLD_PID! 占用, 先结束它
|
|
taskkill /PID !OLD_PID! /F >nul 2>&1
|
|
ping -n 3 127.0.0.1 >nul
|
|
)
|
|
|
|
echo [启动] python api.py
|
|
echo.
|
|
echo 本机打开: http://127.0.0.1:%PORT%
|
|
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4"') do (
|
|
set LAN_IP=%%a
|
|
set LAN_IP=!LAN_IP: =!
|
|
if not "!LAN_IP:~0,8!"=="169.254." echo 内网打开: http://!LAN_IP!:%PORT%
|
|
)
|
|
echo.
|
|
echo 关掉这个窗口或按 Ctrl+C, 服务就停了
|
|
echo.
|
|
|
|
python api.py
|
|
|
|
echo.
|
|
echo [退出] 看板服务已停止
|
|
pause
|