mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:00:44 +00:00
fix(update): restart Windows startup gateway after update
This commit is contained in:
@@ -313,14 +313,19 @@ exit 0
|
||||
expect(scriptPath.endsWith(".cmd")).toBe(true);
|
||||
expect(content).toContain("@echo off");
|
||||
expect(content).toContain("powershell -NoProfile -ExecutionPolicy Bypass -Command");
|
||||
expect(content).not.toContain("-File");
|
||||
expect(content).not.toContain("powershell -NoProfile -ExecutionPolicy Bypass -File");
|
||||
expect(content).toContain('$ErrorActionPreference = "Continue"');
|
||||
expect(content).toContain("gateway-restart.log");
|
||||
expect(content).toContain("$taskName = 'OpenClaw Gateway'");
|
||||
expect(content).toContain("function Invoke-OpenClawSchtasksWithTimeout");
|
||||
expect(content).toContain("function Get-OpenClawScheduledTaskState");
|
||||
expect(content).toContain("function Invoke-OpenClawStartupLauncher");
|
||||
expect(content).toContain("Get-ScheduledTask -TaskName $TaskName");
|
||||
expect(content).toContain("openclaw restart skipped schtasks end");
|
||||
expect(content).toContain(
|
||||
'$launcherPath = Join-Path $env:USERPROFILE ".openclaw\\gateway.cmd"',
|
||||
);
|
||||
expect(content).toContain("openclaw restart launched startup fallback");
|
||||
expectWindowsRestartWaitOrdering(content);
|
||||
expect(content).toContain('del "%~f0" >nul 2>&1');
|
||||
await cleanupScript(scriptPath);
|
||||
@@ -338,6 +343,7 @@ exit 0
|
||||
expect(content).toContain(
|
||||
'Invoke-OpenClawSchtasksWithTimeout -Arguments @("/End", "/TN", $taskName) -TimeoutSeconds 10',
|
||||
);
|
||||
expect(content).toContain("$status = Invoke-OpenClawStartupLauncher");
|
||||
expectWindowsRestartWaitOrdering(content);
|
||||
await cleanupScript(scriptPath);
|
||||
});
|
||||
|
||||
@@ -281,6 +281,23 @@ function Get-OpenClawListenerPids {
|
||||
$listenerPids | Sort-Object -Unique
|
||||
}
|
||||
|
||||
function Invoke-OpenClawStartupLauncher {
|
||||
$launcherPath = Join-Path $env:USERPROFILE ".openclaw\\gateway.cmd"
|
||||
if (-not (Test-Path -LiteralPath $launcherPath)) {
|
||||
Write-RestartLog "openclaw restart startup launcher missing source=update path=$launcherPath"
|
||||
return 1
|
||||
}
|
||||
|
||||
try {
|
||||
Start-Process -FilePath $launcherPath -WindowStyle Hidden | Out-Null
|
||||
Write-RestartLog "openclaw restart launched startup fallback source=update path=$launcherPath"
|
||||
return 0
|
||||
} catch {
|
||||
Write-RestartLog "openclaw restart startup fallback failed source=update error=$($_.Exception.Message)"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
$taskName = ${quotedTaskName}
|
||||
$port = ${port}
|
||||
Write-RestartLog "openclaw restart attempt source=update target=$taskName"
|
||||
@@ -317,6 +334,9 @@ for ($attempt = 1; $attempt -le 10; $attempt++) {
|
||||
}
|
||||
|
||||
$status = Invoke-OpenClawSchtasksWithTimeout -Arguments @("/Run", "/TN", $taskName) -TimeoutSeconds 30
|
||||
if ($status -ne 0) {
|
||||
$status = Invoke-OpenClawStartupLauncher
|
||||
}
|
||||
if ($status -eq 0) {
|
||||
Write-RestartLog "openclaw restart done source=update"
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user