Fix wrapper message handling in manager

This commit is contained in:
2026-07-20 19:04:19 +02:00
parent 860f1ea80d
commit cdbed5e000
7 changed files with 858 additions and 464 deletions
+2 -1
View File
@@ -10,7 +10,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"amqplib": "^2.0.1"
"amqplib": "^2.0.1",
"server-manager-shared": "file:../shared"
},
"devDependencies": {
"@types/amqplib": "^0.10.8",
+3 -2
View File
@@ -4,6 +4,7 @@ import { ServerRegistry, ServerInfo } from "./serverRegistry";
import { randomUUID } from "crypto";
import { generateServerName } from "./nameGenerator";
import { PortManager } from "./portManager";
import { ServerStartCommand, ServerStopCommand } from "server-manager-shared";
export class ServerManager {
@@ -152,7 +153,7 @@ export class ServerManager {
*/
const command = {
const command: ServerStartCommand = {
type:
@@ -261,7 +262,7 @@ export class ServerManager {
const command = {
const command: ServerStopCommand = {
type:
+4 -3
View File
@@ -1,5 +1,6 @@
import { Rabbit } from "./rabbit";
import { ServerRegistry } from "./serverRegistry";
import { ServerStartedEvent, ServerStoppedEvent } from "server-manager-shared";
@@ -58,7 +59,7 @@ export class ServerStatusManager {
const data =
JSON.parse(
msg.content.toString()
);
) as ServerStartedEvent | ServerStoppedEvent;
@@ -136,7 +137,7 @@ export class ServerStatusManager {
serverStarted(data:any){
serverStarted(data: ServerStartedEvent){
@@ -187,7 +188,7 @@ export class ServerStatusManager {
serverStopped(data:any){
serverStopped(data: ServerStoppedEvent){
+18 -7
View File
@@ -2,6 +2,18 @@ import { Rabbit } from "./rabbit";
import { randomUUID } from "crypto";
import { WrapperRegistry, WrapperInfo } from "./wrapperRegistry";
import { ServerRegistry } from "./serverRegistry";
import {
WrapperRegisterMessage,
WrapperHeartbeatMessage,
WrapperStatusMessage,
ServerStartCommand,
ServerStopCommand
} from "server-manager-shared";
type WrapperMessage =
| WrapperRegisterMessage
| WrapperHeartbeatMessage
| WrapperStatusMessage;
export class WrapperManager {
@@ -52,7 +64,7 @@ export class WrapperManager {
const data =
JSON.parse(
msg.content.toString()
);
) as WrapperMessage;
@@ -149,7 +161,7 @@ export class WrapperManager {
async register(data:any){
async register(data: WrapperRegisterMessage){
@@ -225,12 +237,11 @@ export class WrapperManager {
existing.ramFree =
data.ramFree ?? data.ram;
data.ram;
existing.servers =
data.servers ?? existing.servers;
// servers are updated via wrapper.status, not wrapper.register
@@ -391,7 +402,7 @@ export class WrapperManager {
heartbeat(data:any){
heartbeat(data: WrapperHeartbeatMessage){
@@ -427,7 +438,7 @@ export class WrapperManager {
wrapperId:string,
command:any
command: ServerStartCommand | ServerStopCommand
){