aboutsummaryrefslogtreecommitdiff
path: root/src/server/DashSession/Session/agents/monitor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/DashSession/Session/agents/monitor.ts')
-rw-r--r--src/server/DashSession/Session/agents/monitor.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts
index 9cb5ab576..0f469285e 100644
--- a/src/server/DashSession/Session/agents/monitor.ts
+++ b/src/server/DashSession/Session/agents/monitor.ts
@@ -1,7 +1,8 @@
import { ExitHandler } from "./applied_session_agent";
import { Configuration, configurationSchema, defaultConfig, Identifiers, colorMapping } from "../utilities/session_config";
import Repl, { ReplAction } from "../utilities/repl";
-import { isWorker, setupMaster, on, Worker, fork } from "cluster";
+import * as _cluster from "cluster";
+import { Worker } from "cluster";
import { manage, MessageHandler, ErrorLike } from "./promisified_ipc_manager";
import { red, cyan, white, yellow, blue } from "colors";
import { exec, ExecOptions } from "child_process";
@@ -10,6 +11,11 @@ import { Utilities } from "../utilities/utilities";
import { readFileSync } from "fs";
import IPCMessageReceiver from "./process_message_router";
import { ServerWorker } from "./server_worker";
+const cluster = _cluster as any;
+const isWorker = cluster.isWorker;
+const setupMaster = cluster.setupPrimary;
+const on = cluster.on;
+const fork = cluster.fork;
/**
* Validates and reads the configuration file, accordingly builds a child process factory
@@ -20,7 +26,7 @@ export class Monitor extends IPCMessageReceiver {
private finalized = false;
private exitHandlers: ExitHandler[] = [];
private readonly config: Configuration;
- private activeWorker: Worker | undefined;
+ private activeWorker: Worker| undefined;
private key: string | undefined;
private repl: Repl;
@@ -281,8 +287,11 @@ export class Monitor extends IPCMessageReceiver {
pollingIntervalSeconds: polling.intervalSeconds,
session_key: key
});
- Monitor.IPCManager = manage(this.activeWorker.process, this.handlers);
+ if (this.activeWorker) {
+ Monitor.IPCManager = manage(this.activeWorker.process, this.handlers);
+ }
this.mainLog(cyan(`spawned new server worker with process id ${this.activeWorker?.process.pid}`));
+
}
}