fix: 修复部署问题

This commit is contained in:
Daniel
2026-04-07 17:01:13 +08:00
parent d22d6bb73b
commit 4879d2e8c5
15 changed files with 280 additions and 11 deletions

View File

@@ -0,0 +1,41 @@
param(
[ValidateSet("start", "stop", "restart", "status")]
[string]$Action = "start",
[string]$Distro = ""
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path))
$ProjectRoot = Join-Path $Root "edge_node"
if (!(Get-Command wsl -ErrorAction SilentlyContinue)) {
throw "WSL command not found. Please install WSL first."
}
if ([string]::IsNullOrWhiteSpace($Distro)) {
$linuxRoot = (wsl -- wslpath -a "$Root").Trim()
} else {
$linuxRoot = (wsl -d $Distro -- wslpath -a "$Root").Trim()
}
if ([string]::IsNullOrWhiteSpace($linuxRoot)) {
throw "Failed to resolve WSL path for project root: $Root"
}
switch ($Action) {
"start" { $target = "edge_node/scripts/start.sh" }
"stop" { $target = "edge_node/scripts/stop.sh" }
"restart" { $target = "edge_node/scripts/restart.sh" }
"status" {
$bash = "cd '$linuxRoot' && if [ -f edge_node/runtime/pids/worker.pid ] && kill -0 `$(cat edge_node/runtime/pids/worker.pid) >/dev/null 2>&1; then echo '[OK] worker running'; else echo '[INFO] worker not running'; fi; if [ -f edge_node/runtime/pids/edge_client.pid ] && kill -0 `$(cat edge_node/runtime/pids/edge_client.pid) >/dev/null 2>&1; then echo '[OK] edge_client running'; else echo '[INFO] edge_client not running'; fi"
if ([string]::IsNullOrWhiteSpace($Distro)) { wsl -- bash -lc "$bash" } else { wsl -d $Distro -- bash -lc "$bash" }
exit 0
}
}
$bashCommand = "cd '$linuxRoot' && chmod +x edge_node/scripts/start.sh edge_node/scripts/stop.sh edge_node/scripts/restart.sh scripts/start_edge_device_local.sh scripts/stop_edge_device_local.sh scripts/restart_edge_device_local.sh && bash $target"
if ([string]::IsNullOrWhiteSpace($Distro)) {
wsl -- bash -lc "$bashCommand"
} else {
wsl -d $Distro -- bash -lc "$bashCommand"
}