在 Windows 上检查 OpenELM 部署状态
一、先确认部署形态
二、通用快速检查清单
三、按部署方式执行对照检查
| 部署方式 | 关键检查 | 常用命令示例 | ||
|---|---|---|---|---|
| Windows 服务 | 服务是否 Running、启动类型、最近错误 | Get-Service openelm;sc query openelm;eventvwr.msc | ||
| Python 脚本 | 进程是否存在、端口占用、日志输出 | Get-Process python;netstat -ano | findstr ":8000";Get-Content logs/app.log -Tail 50 -Wait | |
| Docker Desktop | 容器是否 Running、端口映射、日志 | docker ps -a | findstr openelm;docker logs -f openelm;docker port openelm | |
| WSL(Linux 内) | 进程/端口/日志(在 WSL 中执行) | ps aux | grep openelm;ss -tuln | grep 8000;tail -f /var/log/openelm.log 或 journalctl -u openelm -f |
四、常见症状与定位路径
五、一键诊断脚本示例(PowerShell)
# 参数
$ServiceName = "openelm"
$Port = 8000
$LogPath = "C:\logs\app.log"
Write-Host "=== OpenELM 部署状态检查 ===" -ForegroundColor Cyan
# 1) 服务状态
$svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($svc) {
Write-Host "[服务] $($svc.Status) (启动类型: $($svc.StartType))" -ForegroundColor $(if ($svc.Status -eq 'Running') { 'Green' } else { 'Yellow' })
} else {
Write-Host "[服务] 未找到服务: $ServiceName" -ForegroundColor Red
}
# 2) 进程
$procs = Get-Process | Where-Object { $_.ProcessName -like '*python*' -or $_.Name -eq $ServiceName }
if ($procs) {
$procs | Select-Object Id, ProcessName, CPU, WorkingSet | Format-Table -AutoSize
} else {
Write-Host "[进程] 未找到相关 Python/服务进程" -ForegroundColor Red
}
# 3) 端口
$tcp = Get-NetTCPConnection -LocalPort $Port -ErrorAction SilentlyContinue
if ($tcp) {
Write-Host "[端口] $Port 已被 PID $($tcp.OwningProcess) 占用" -ForegroundColor Green
} else {
Write-Host "[端口] $Port 未被监听" -ForegroundColor Red
}
# 4) 本地连通性
$conn = Test-NetConnection -ComputerName 127.0.0.1 -Port $Port
Write-Host "[连通] 127.0.0.1:$Port -> $($conn.TcpTestSucceeded)" -ForegroundColor $(if ($conn.TcpTestSucceeded) { 'Green' } else { 'Red' })
# 5) 日志尾部
if (Test-Path $LogPath) {
Write-Host "[日志] 最近 20 行:" -ForegroundColor Cyan
Get-Content -Path $LogPath -Tail 20
} else {
Write-Host "[日志] 未找到日志文件: $LogPath" -ForegroundColor Yellow
}提示:若你采用 Docker 或 WSL,优先在对应环境中执行相应命令;Windows 服务与 Python 脚本的检查互不冲突,可并行使用以交叉验证。