Fix wrapper message handling in manager
This commit is contained in:
@@ -10,7 +10,8 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"amqplib": "^2.0.1"
|
"amqplib": "^2.0.1",
|
||||||
|
"server-manager-shared": "file:../shared"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/amqplib": "^0.10.8",
|
"@types/amqplib": "^0.10.8",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ServerRegistry, ServerInfo } from "./serverRegistry";
|
|||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { generateServerName } from "./nameGenerator";
|
import { generateServerName } from "./nameGenerator";
|
||||||
import { PortManager } from "./portManager";
|
import { PortManager } from "./portManager";
|
||||||
|
import { ServerStartCommand, ServerStopCommand } from "server-manager-shared";
|
||||||
|
|
||||||
|
|
||||||
export class ServerManager {
|
export class ServerManager {
|
||||||
@@ -152,7 +153,7 @@ export class ServerManager {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const command = {
|
const command: ServerStartCommand = {
|
||||||
|
|
||||||
|
|
||||||
type:
|
type:
|
||||||
@@ -261,7 +262,7 @@ export class ServerManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const command = {
|
const command: ServerStopCommand = {
|
||||||
|
|
||||||
|
|
||||||
type:
|
type:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Rabbit } from "./rabbit";
|
import { Rabbit } from "./rabbit";
|
||||||
import { ServerRegistry } from "./serverRegistry";
|
import { ServerRegistry } from "./serverRegistry";
|
||||||
|
import { ServerStartedEvent, ServerStoppedEvent } from "server-manager-shared";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ export class ServerStatusManager {
|
|||||||
const data =
|
const data =
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
msg.content.toString()
|
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){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,18 @@ import { Rabbit } from "./rabbit";
|
|||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { WrapperRegistry, WrapperInfo } from "./wrapperRegistry";
|
import { WrapperRegistry, WrapperInfo } from "./wrapperRegistry";
|
||||||
import { ServerRegistry } from "./serverRegistry";
|
import { ServerRegistry } from "./serverRegistry";
|
||||||
|
import {
|
||||||
|
WrapperRegisterMessage,
|
||||||
|
WrapperHeartbeatMessage,
|
||||||
|
WrapperStatusMessage,
|
||||||
|
ServerStartCommand,
|
||||||
|
ServerStopCommand
|
||||||
|
} from "server-manager-shared";
|
||||||
|
|
||||||
|
type WrapperMessage =
|
||||||
|
| WrapperRegisterMessage
|
||||||
|
| WrapperHeartbeatMessage
|
||||||
|
| WrapperStatusMessage;
|
||||||
|
|
||||||
|
|
||||||
export class WrapperManager {
|
export class WrapperManager {
|
||||||
@@ -52,7 +64,7 @@ export class WrapperManager {
|
|||||||
const data =
|
const data =
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
msg.content.toString()
|
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 =
|
existing.ramFree =
|
||||||
data.ramFree ?? data.ram;
|
data.ram;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
existing.servers =
|
// servers are updated via wrapper.status, not wrapper.register
|
||||||
data.servers ?? existing.servers;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -391,7 +402,7 @@ export class WrapperManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
heartbeat(data:any){
|
heartbeat(data: WrapperHeartbeatMessage){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -427,7 +438,7 @@ export class WrapperManager {
|
|||||||
|
|
||||||
wrapperId:string,
|
wrapperId:string,
|
||||||
|
|
||||||
command:any
|
command: ServerStartCommand | ServerStopCommand
|
||||||
|
|
||||||
){
|
){
|
||||||
|
|
||||||
|
|||||||
Generated
+821
-442
File diff suppressed because it is too large
Load Diff
+7
-6
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"name": "server-manager",
|
||||||
"workspaces": [
|
"private": true,
|
||||||
"manager",
|
"workspaces": [
|
||||||
"wrapper",
|
"manager",
|
||||||
"shared"
|
"wrapper",
|
||||||
]
|
"shared"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,10 +3,10 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.json"
|
"build": "tsc -p tsconfig.json"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"devDependencies": {
|
||||||
"devDependencies": {}
|
"typescript": "^7.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user