Phase8
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 9s
CI / Go — edge-gateway build (push) Successful in 17s

This commit is contained in:
smueller
2026-06-26 13:33:03 +02:00
parent ab21f53cdd
commit b335f6a497
39 changed files with 1477 additions and 20 deletions

View File

@@ -15,6 +15,7 @@
"@hexahost/catalog": "workspace:*",
"@hexahost/config": "workspace:*",
"@hexahost/database": "workspace:*",
"@hexahost/dns": "workspace:*",
"@hexahost/metering": "workspace:*",
"@hexahost/scheduler": "workspace:*",
"@hexahost/storage": "workspace:*",

View File

@@ -1,6 +1,7 @@
import { randomUUID } from 'node:crypto';
import { prisma } from '@hexahost/database';
import { assignJoinAddress } from '@hexahost/dns';
import { selectNodeForAllocation } from '@hexahost/scheduler';
import { Job } from 'bullmq';
import { z } from 'zod';
@@ -11,7 +12,6 @@ import { loadNodeSnapshots } from '../node-snapshots';
import { publishNodeCommand, waitForNodeResponse } from '../redis';
import { transitionServerStatus } from '../server-state';
const BASE_HOST_PORT = 25565;
const PROVISION_TIMEOUT_MS = 5 * 60 * 1000;
export const provisionServerJobSchema = z.object({
@@ -23,6 +23,11 @@ function buildDataPath(serverId: string): string {
}
async function findAvailableHostPort(nodeId: string): Promise<number> {
const node = await prisma.gameNode.findUniqueOrThrow({
where: { id: nodeId },
select: { portRangeStart: true, portRangeEnd: true },
});
const [allocations, servers] = await Promise.all([
prisma.gameServerAllocation.findMany({
where: { nodeId, status: 'ACTIVE' },
@@ -44,9 +49,12 @@ async function findAvailableHostPort(nodeId: string): Promise<number> {
}
}
let port = BASE_HOST_PORT;
let port = node.portRangeStart;
while (usedPorts.has(port)) {
port += 1;
if (port > node.portRangeEnd) {
throw new Error(`No free host port in range ${node.portRangeStart}-${node.portRangeEnd}`);
}
}
return port;
@@ -171,6 +179,8 @@ export async function processProvisionServerJob(job: Job): Promise<{ status: str
correlationId: messageId,
});
await assignJoinAddress(serverId);
logger.info({ serverId, nodeId: node.id, hostPort }, 'Server provisioned');
return { status: 'stopped' };
}

File diff suppressed because one or more lines are too long