mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。 Made-with: Cursor
This commit is contained in:
parent
ba3836f00f
commit
4a23b715a2
498 changed files with 2760 additions and 2200 deletions
62
runtime/operations/scripts/stop_gateway.ps1
Normal file
62
runtime/operations/scripts/stop_gateway.ps1
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
param(
|
||||
[int]$Port = 8787,
|
||||
[switch]$Force = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-Step([string]$msg) {
|
||||
Write-Host "==> $msg" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
function Warn([string]$msg) {
|
||||
Write-Host "[WARN] $msg" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
function Kill-ProcId([int]$procId) {
|
||||
try {
|
||||
Stop-Process -Id $procId -Force
|
||||
Write-Host "Stopped PID=$procId" -ForegroundColor Green
|
||||
return $true
|
||||
} catch {
|
||||
Warn "Failed to stop PID=$procId : $($_.Exception.Message)"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
$pidFile = Join-Path $runDir "gateway.pid"
|
||||
|
||||
Write-Step "Stopping gateway"
|
||||
|
||||
if (Test-Path $pidFile) {
|
||||
$raw = (Get-Content $pidFile -ErrorAction SilentlyContinue | Select-Object -First 1)
|
||||
$procId = 0
|
||||
[void][int]::TryParse([string]$raw, [ref]$procId)
|
||||
if ($procId -gt 0) {
|
||||
$ok = Kill-ProcId -procId $procId
|
||||
if ($ok) {
|
||||
Remove-Item $pidFile -Force -ErrorAction SilentlyContinue
|
||||
exit 0
|
||||
}
|
||||
if (-not $Force) { exit 1 }
|
||||
}
|
||||
}
|
||||
|
||||
Write-Step "No PID file; attempting to stop by port $Port"
|
||||
try {
|
||||
$conns = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue
|
||||
if (-not $conns) {
|
||||
Warn "No listener found on port $Port"
|
||||
exit 0
|
||||
}
|
||||
$pids = $conns | Select-Object -ExpandProperty OwningProcess -Unique
|
||||
foreach ($p in $pids) {
|
||||
if ($p -gt 0) { [void](Kill-ProcId -procId $p) }
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Warn "Stop by port failed: $($_.Exception.Message)"
|
||||
if (-not $Force) { exit 1 }
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue