Repair VoidBot Idunn pulse launcher
This commit is contained in:
parent
8b4e043164
commit
8a21aeffcb
4 changed files with 59 additions and 26 deletions
|
|
@ -11,7 +11,7 @@ $ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||||
$runnerScript = Join-Path $PSScriptRoot "run-gamecult-orchestrator.ps1"
|
$runnerScript = Join-Path $PSScriptRoot "run-gamecult-orchestrator.ps1"
|
||||||
$hiddenLauncher = Join-Path $PSScriptRoot "run-hidden-powershell.vbs"
|
$hiddenLauncher = Join-Path $PSScriptRoot "start-gamecult-orchestrator-hidden.vbs"
|
||||||
|
|
||||||
if ($IntervalMinutes -lt 1) {
|
if ($IntervalMinutes -lt 1) {
|
||||||
throw "IntervalMinutes must be at least 1."
|
throw "IntervalMinutes must be at least 1."
|
||||||
|
|
@ -26,7 +26,7 @@ if (-not (Test-Path -LiteralPath $hiddenLauncher)) {
|
||||||
$startAt = (Get-Date).AddMinutes(1)
|
$startAt = (Get-Date).AddMinutes(1)
|
||||||
$action = New-ScheduledTaskAction `
|
$action = New-ScheduledTaskAction `
|
||||||
-Execute "wscript.exe" `
|
-Execute "wscript.exe" `
|
||||||
-Argument "//B //nologo `"$hiddenLauncher`" -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$runnerScript`"" `
|
-Argument "//B //nologo `"$hiddenLauncher`"" `
|
||||||
-WorkingDirectory $repoRoot
|
-WorkingDirectory $repoRoot
|
||||||
$trigger = New-ScheduledTaskTrigger -Once -At $startAt -RepetitionInterval (New-TimeSpan -Minutes $IntervalMinutes) -RepetitionDuration (New-TimeSpan -Days 3650)
|
$trigger = New-ScheduledTaskTrigger -Once -At $startAt -RepetitionInterval (New-TimeSpan -Minutes $IntervalMinutes) -RepetitionDuration (New-TimeSpan -Days 3650)
|
||||||
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 30) -MultipleInstances IgnoreNew
|
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 30) -MultipleInstances IgnoreNew
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,15 @@ async function publishIdunnRudpHealth(publisher, health) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const connect = session.createConnect(Date.now(), new Uint8Array());
|
const connect = session.createConnect(Date.now(), new Uint8Array());
|
||||||
await receiveAccept(receiver, session, publisher.endpoint, connect, 5000);
|
await sendPacket(socket, publisher.endpoint, connect);
|
||||||
|
await receiveUntil(
|
||||||
|
receiver,
|
||||||
|
session,
|
||||||
|
publisher.endpoint,
|
||||||
|
(packet) => packet.packetType === "accept",
|
||||||
|
5000,
|
||||||
|
"accept",
|
||||||
|
);
|
||||||
|
|
||||||
const record = {
|
const record = {
|
||||||
daemonId: publisher.daemonId,
|
daemonId: publisher.daemonId,
|
||||||
|
|
@ -91,31 +99,11 @@ async function publishIdunnRudpHealth(publisher, health) {
|
||||||
await ack;
|
await ack;
|
||||||
} finally {
|
} finally {
|
||||||
receiver.close();
|
receiver.close();
|
||||||
socket.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function receiveAccept(receiver, session, endpoint, connectPacket, timeoutMs) {
|
|
||||||
const deadline = Date.now() + timeoutMs;
|
|
||||||
let nextConnectMs = 0;
|
|
||||||
while (Date.now() < deadline) {
|
|
||||||
const now = Date.now();
|
|
||||||
if (now >= nextConnectMs) {
|
|
||||||
await sendPacket(receiver.socket, endpoint, connectPacket);
|
|
||||||
nextConnectMs = now + 100;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const packet = await receiver.next(Math.min(100, deadline - now), "accept");
|
socket.unref();
|
||||||
const result = session.receive(packet, Date.now());
|
} catch {}
|
||||||
if (result.reply) {
|
await closeSocket(socket);
|
||||||
throw new Error("VoidBot RUDP health publisher received an unexpected reply-required packet.");
|
|
||||||
}
|
|
||||||
if (packet.packetType === "accept") return;
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "ETIMEDOUT") throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new Error(`timed out waiting for Idunn RUDP accept response after ${timeoutMs}ms`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bindSocket(socket, endpoint) {
|
async function bindSocket(socket, endpoint) {
|
||||||
|
|
@ -274,6 +262,23 @@ async function sendPacket(socket, endpoint, packet) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function closeSocket(socket) {
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
let settled = false;
|
||||||
|
const finish = () => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
socket.once("close", finish);
|
||||||
|
try {
|
||||||
|
socket.close(finish);
|
||||||
|
} catch {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
main().catch((error) => {
|
main().catch((error) => {
|
||||||
console.error(error?.stack || String(error));
|
console.error(error?.stack || String(error));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
19
scripts/start-gamecult-orchestrator-hidden.vbs
Normal file
19
scripts/start-gamecult-orchestrator-hidden.vbs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Option Explicit
|
||||||
|
|
||||||
|
Dim shell
|
||||||
|
Dim scriptDir
|
||||||
|
Dim runnerScript
|
||||||
|
Dim command
|
||||||
|
|
||||||
|
Set shell = CreateObject("WScript.Shell")
|
||||||
|
scriptDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
|
||||||
|
runnerScript = scriptDir & "\run-gamecult-orchestrator.ps1"
|
||||||
|
|
||||||
|
command = QuoteArg(shell.ExpandEnvironmentStrings("%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"))
|
||||||
|
command = command & " -NoProfile -NonInteractive -ExecutionPolicy Bypass -File " & QuoteArg(runnerScript)
|
||||||
|
|
||||||
|
shell.Run command, 0, False
|
||||||
|
|
||||||
|
Function QuoteArg(value)
|
||||||
|
QuoteArg = """" & Replace(value, """", """""") & """"
|
||||||
|
End Function
|
||||||
|
|
@ -697,6 +697,15 @@ $status.completedAt = (Get-Date).ToString("o")
|
||||||
$status.ready = $true
|
$status.ready = $true
|
||||||
Write-StatusFile -Path $statusPath -Status $status
|
Write-StatusFile -Path $statusPath -Status $status
|
||||||
|
|
||||||
|
$installOrchestratorTaskScript = Join-Path $PSScriptRoot "install-gamecult-orchestrator-task.ps1"
|
||||||
|
if (Test-Path -LiteralPath $installOrchestratorTaskScript) {
|
||||||
|
Write-Host "Refreshing GameCult Local Orchestrator task..."
|
||||||
|
& $installOrchestratorTaskScript -RunNow
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "install-gamecult-orchestrator-task.ps1 failed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "VoidBot stack is up."
|
Write-Host "VoidBot stack is up."
|
||||||
Write-Host "Status: $statusPath"
|
Write-Host "Status: $statusPath"
|
||||||
Write-Host "Bot log: $botOut"
|
Write-Host "Bot log: $botOut"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue