Fix wrapper message handling in manager
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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){
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user