From b19972afc64bb9029b78c633e1841988af76adab Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Thu, 15 Oct 2020 11:54:46 -0700 Subject: With a MONITORED=true in .env, this should now work --- src/server/DashSession/Session/agents/monitor.ts | 6 +++--- src/server/DashSession/Session/utilities/session_config.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server/DashSession/Session') diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index ee8afee65..044a841ae 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -22,7 +22,7 @@ export class Monitor extends IPCMessageReceiver { private readonly config: Configuration; private activeWorker: Worker | undefined; private key: string | undefined; - // private repl: Repl; + private repl: Repl; public static Create() { if (isWorker) { @@ -46,7 +46,7 @@ export class Monitor extends IPCMessageReceiver { this.configureInternalHandlers(); this.config = this.loadAndValidateConfiguration(); this.initializeClusterFunctions(); - // this.repl = this.initializeRepl(); + this.repl = this.initializeRepl(); } protected configureInternalHandlers = () => { @@ -119,7 +119,7 @@ export class Monitor extends IPCMessageReceiver { * that can invoke application logic external to this module */ public addReplCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { - // this.repl.registerCommand(basename, argPatterns, action); + this.repl.registerCommand(basename, argPatterns, action); } public exec = (command: string, options?: ExecOptions) => { diff --git a/src/server/DashSession/Session/utilities/session_config.ts b/src/server/DashSession/Session/utilities/session_config.ts index b0e65dde4..bde98e9d2 100644 --- a/src/server/DashSession/Session/utilities/session_config.ts +++ b/src/server/DashSession/Session/utilities/session_config.ts @@ -19,7 +19,7 @@ const identifierProperties: Schema = { const portProperties: Schema = { type: "number", - minimum: 1024, + minimum: 443, maximum: 65535 }; -- cgit v1.2.3-70-g09d2 From f072617e9e14d49ce6099fe7c930d253801ef44f Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 20 Oct 2020 22:04:58 -0700 Subject: Fixed crash report --- src/server/DashSession/DashSessionAgent.ts | 6 +++--- src/server/DashSession/Session/agents/monitor.ts | 4 ++-- .../DashSession/Session/agents/promisified_ipc_manager.ts | 4 ++-- src/server/DashSession/Session/agents/server_worker.ts | 10 +++++++++- tsconfig.json | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/server/DashSession/Session') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index ab3dfffcc..5a23f8216 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -10,7 +10,7 @@ import * as Archiver from "archiver"; import { resolve } from "path"; import rimraf = require("rimraf"); import { AppliedSessionAgent, ExitHandler } from "./Session/agents/applied_session_agent"; -import { ServerWorker } from "./Session/agents/server_worker"; +import { ServerWorker, DeconstructedError } from "./Session/agents/server_worker"; import { Monitor } from "./Session/agents/monitor"; import { MessageHandler } from "./Session/agents/promisified_ipc_manager"; @@ -70,7 +70,7 @@ export class DashSessionAgent extends AppliedSessionAgent { * Prepares the body of the email with information regarding a crash event. */ private _crashInstructions: string | undefined; - private generateCrashInstructions({ name, message, stack }: Error): string { + private generateCrashInstructions({ name, message, stack }: DeconstructedError): string { if (!this._crashInstructions) { this._crashInstructions = readFileSync(resolve(__dirname, "./templates/crash_instructions.txt"), { encoding: "utf8" }); } @@ -109,7 +109,7 @@ export class DashSessionAgent extends AppliedSessionAgent { /** * This sends an email with the generated crash report. */ - private dispatchCrashReport: MessageHandler<{ error: Error }> = async ({ error: crashCause }) => { + private dispatchCrashReport: MessageHandler<{ error: DeconstructedError }> = async ({ error: crashCause }) => { const { mainLog } = this.sessionMonitor; const { notificationRecipient } = DashSessionAgent; const error = await Email.dispatch({ diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index 044a841ae..1bbbae0a9 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -9,7 +9,7 @@ import { validate, ValidationError } from "jsonschema"; import { Utilities } from "../utilities/utilities"; import { readFileSync } from "fs"; import IPCMessageReceiver from "./process_message_router"; -import { ServerWorker } from "./server_worker"; +import { ServerWorker, DeconstructedError } from "./server_worker"; /** * Validates and reads the configuration file, accordingly builds a child process factory @@ -90,7 +90,7 @@ export class Monitor extends IPCMessageReceiver { } public readonly coreHooks = Object.freeze({ - onCrashDetected: (listener: MessageHandler<{ error: Error }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), + onCrashDetected: (listener: MessageHandler<{ error: DeconstructedError }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), onServerRunning: (listener: MessageHandler<{ isFirstTime: boolean }>) => this.on(Monitor.IntrinsicEvents.ServerRunning, listener) }); diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts index feff568e1..fc32c48b4 100644 --- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -162,8 +162,8 @@ export class PromisifiedIPCManager { } if (!this.isDestroyed && this.target.send) { const metadata = { id, isResponse: true }; - const response: Response = { results , error }; - const message = { name, args: response , metadata }; + const response: Response = { results, error }; + const message = { name, args: response, metadata }; delete this.pendingMessages[id]; this.target.send(message); } diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts index 976d27226..e3ec4e1c6 100644 --- a/src/server/DashSession/Session/agents/server_worker.ts +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -112,7 +112,9 @@ export class ServerWorker extends IPCMessageReceiver { private proactiveUnplannedExit = async (error: Error): Promise => { this.shouldServerBeResponsive = false; // communicates via IPC to the master thread that it should dispatch a crash notification email - this.emit(Monitor.IntrinsicEvents.CrashDetected, { error }); + const { name, message, stack } = error; + const deconstructed_error: DeconstructedError = { name, message, stack }; + this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: deconstructed_error }); await this.executeExitHandlers(error); // notify master thread (which will log update in the console) of crash event via IPC this.lifecycleNotification(red(`crash event detected @ ${new Date().toUTCString()}`)); @@ -157,4 +159,10 @@ export class ServerWorker extends IPCMessageReceiver { this.pollServer(); } +} + +export interface DeconstructedError { + name: string; + message: string; + stack: string | undefined; } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index b06cec79f..f688f18ea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "./src/typings" ], "types": [ - "youtube" + "youtube", + "node" ] }, // "exclude": [ -- cgit v1.2.3-70-g09d2 From f9f7ac461534a3cfc9a03490d7803e83ea4d8aad Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 21 Oct 2020 01:11:17 -0700 Subject: Replaced redundant DeconstructedError with ErrorLike --- src/server/DashSession/DashSessionAgent.ts | 8 ++++---- src/server/DashSession/Session/agents/monitor.ts | 6 +++--- .../DashSession/Session/agents/promisified_ipc_manager.ts | 4 ++-- src/server/DashSession/Session/agents/server_worker.ts | 10 ++-------- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src/server/DashSession/Session') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index a094b3781..03ba33fee 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -10,9 +10,9 @@ import * as Archiver from "archiver"; import { resolve } from "path"; import rimraf = require("rimraf"); import { AppliedSessionAgent, ExitHandler } from "./Session/agents/applied_session_agent"; -import { ServerWorker, DeconstructedError } from "./Session/agents/server_worker"; +import { ServerWorker } from "./Session/agents/server_worker"; import { Monitor } from "./Session/agents/monitor"; -import { MessageHandler } from "./Session/agents/promisified_ipc_manager"; +import { MessageHandler, ErrorLike } from "./Session/agents/promisified_ipc_manager"; /** * If we're the monitor (master) thread, we should launch the monitor logic for the session. @@ -70,7 +70,7 @@ export class DashSessionAgent extends AppliedSessionAgent { * Prepares the body of the email with information regarding a crash event. */ private _crashInstructions: string | undefined; - private generateCrashInstructions({ name, message, stack }: DeconstructedError): string { + private generateCrashInstructions({ name, message, stack }: ErrorLike): string { if (!this._crashInstructions) { this._crashInstructions = readFileSync(resolve(__dirname, "./templates/crash_instructions.txt"), { encoding: "utf8" }); } @@ -109,7 +109,7 @@ export class DashSessionAgent extends AppliedSessionAgent { /** * This sends an email with the generated crash report. */ - private dispatchCrashReport: MessageHandler<{ error: DeconstructedError }> = async ({ error: crashCause }) => { + private dispatchCrashReport: MessageHandler<{ error: ErrorLike }> = async ({ error: crashCause }) => { const { mainLog } = this.sessionMonitor; const { notificationRecipient } = DashSessionAgent; const error = await Email.dispatch({ diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index 1bbbae0a9..0fdaf07ff 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -2,14 +2,14 @@ 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 { manage, MessageHandler } from "./promisified_ipc_manager"; +import { manage, MessageHandler, ErrorLike } from "./promisified_ipc_manager"; import { red, cyan, white, yellow, blue } from "colors"; import { exec, ExecOptions } from "child_process"; import { validate, ValidationError } from "jsonschema"; import { Utilities } from "../utilities/utilities"; import { readFileSync } from "fs"; import IPCMessageReceiver from "./process_message_router"; -import { ServerWorker, DeconstructedError } from "./server_worker"; +import { ServerWorker } from "./server_worker"; /** * Validates and reads the configuration file, accordingly builds a child process factory @@ -90,7 +90,7 @@ export class Monitor extends IPCMessageReceiver { } public readonly coreHooks = Object.freeze({ - onCrashDetected: (listener: MessageHandler<{ error: DeconstructedError }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), + onCrashDetected: (listener: MessageHandler<{ error: ErrorLike }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), onServerRunning: (listener: MessageHandler<{ isFirstTime: boolean }>) => this.on(Monitor.IntrinsicEvents.ServerRunning, listener) }); diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts index fc32c48b4..95aa686e6 100644 --- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -43,8 +43,8 @@ type InternalMessageHandler = (message: InternalMessage) => (any | Promise) * Allows for the transmission of the error's key features over IPC. */ export interface ErrorLike { - name?: string; - message?: string; + name: string; + message: string; stack?: string; } diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts index e3ec4e1c6..afa5fc68d 100644 --- a/src/server/DashSession/Session/agents/server_worker.ts +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -1,6 +1,6 @@ import { ExitHandler } from "./applied_session_agent"; import { isMaster } from "cluster"; -import { manage } from "./promisified_ipc_manager"; +import { manage, ErrorLike } from "./promisified_ipc_manager"; import IPCMessageReceiver from "./process_message_router"; import { red, green, white, yellow } from "colors"; import { get } from "request-promise"; @@ -113,7 +113,7 @@ export class ServerWorker extends IPCMessageReceiver { this.shouldServerBeResponsive = false; // communicates via IPC to the master thread that it should dispatch a crash notification email const { name, message, stack } = error; - const deconstructed_error: DeconstructedError = { name, message, stack }; + const deconstructed_error: ErrorLike = { name, message, stack }; this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: deconstructed_error }); await this.executeExitHandlers(error); // notify master thread (which will log update in the console) of crash event via IPC @@ -160,9 +160,3 @@ export class ServerWorker extends IPCMessageReceiver { } } - -export interface DeconstructedError { - name: string; - message: string; - stack: string | undefined; -} \ No newline at end of file -- cgit v1.2.3-70-g09d2