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

This commit is contained in:
smueller
2026-06-26 13:11:28 +02:00
parent d29a02f2a4
commit 49a98ee31d
81 changed files with 1462 additions and 53 deletions

View File

@@ -110,10 +110,18 @@ export class NodesService {
}
async markNodeOnline(nodeId: string, agentVersion?: string): Promise<void> {
const node = await this.prisma.gameNode.findUnique({ where: { id: nodeId } });
const nextStatus =
node?.status === 'UNREACHABLE' || node?.status === 'OFFLINE'
? 'ONLINE'
: node?.status === 'MAINTENANCE' || node?.status === 'DRAINING'
? node.status
: 'ONLINE';
await this.prisma.gameNode.update({
where: { id: nodeId },
data: {
status: 'ONLINE',
status: nextStatus,
lastHeartbeatAt: new Date(),
enrolledAt: new Date(),
agentVersion,
@@ -172,17 +180,35 @@ export class NodesService {
payload?: Record<string, unknown>,
): Promise<void> {
const now = new Date();
const node = await this.prisma.gameNode.findUnique({ where: { id: nodeId } });
const nextStatus =
node?.status === 'UNREACHABLE'
? 'ONLINE'
: node?.status === 'MAINTENANCE' || node?.status === 'DRAINING'
? node.status
: 'ONLINE';
await this.prisma.$transaction([
this.prisma.gameNode.update({
where: { id: nodeId },
data: {
lastHeartbeatAt: now,
status: 'ONLINE',
status: nextStatus,
agentVersion:
typeof payload?.['agentVersion'] === 'string'
? payload['agentVersion']
: undefined,
metadata: payload
? ({
cpuUsagePercent: payload['cpuUsagePercent'],
memoryUsedBytes: payload['memoryUsedBytes'],
memoryTotalBytes: payload['memoryTotalBytes'],
diskUsedBytes: payload['diskUsedBytes'],
diskTotalBytes: payload['diskTotalBytes'],
runningServers: payload['runningServers'],
} as Prisma.InputJsonValue)
: undefined,
},
}),
this.prisma.gameNodeHeartbeat.create({