Repair VoidBot Idunn pulse launcher

This commit is contained in:
Meta Vens 2026-06-17 03:00:51 +01:00
commit 8a21aeffcb
4 changed files with 59 additions and 26 deletions

View file

@ -11,7 +11,7 @@ $ProgressPreference = "SilentlyContinue"
$repoRoot = Split-Path -Parent $PSScriptRoot
$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) {
throw "IntervalMinutes must be at least 1."
@ -26,7 +26,7 @@ if (-not (Test-Path -LiteralPath $hiddenLauncher)) {
$startAt = (Get-Date).AddMinutes(1)
$action = New-ScheduledTaskAction `
-Execute "wscript.exe" `
-Argument "//B //nologo `"$hiddenLauncher`" -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$runnerScript`"" `
-Argument "//B //nologo `"$hiddenLauncher`"" `
-WorkingDirectory $repoRoot
$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

View file

@ -43,7 +43,15 @@ async function publishIdunnRudpHealth(publisher, health) {
try {
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 = {
daemonId: publisher.daemonId,
@ -91,31 +99,11 @@ async function publishIdunnRudpHealth(publisher, health) {
await ack;
} finally {
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 {
const packet = await receiver.next(Math.min(100, deadline - now), "accept");
const result = session.receive(packet, Date.now());
if (result.reply) {
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;
}
socket.unref();
} catch {}
await closeSocket(socket);
}
throw new Error(`timed out waiting for Idunn RUDP accept response after ${timeoutMs}ms`);
}
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) => {
console.error(error?.stack || String(error));
process.exit(1);

View 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

View file

@ -697,6 +697,15 @@ $status.completedAt = (Get-Date).ToString("o")
$status.ready = $true
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 "Status: $statusPath"
Write-Host "Bot log: $botOut"