aboutsummaryrefslogtreecommitdiff
path: root/src/server/DashSession/DashSessionAgent.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2020-01-11 09:54:48 -0500
committerSam Wilkins <samwilkins333@gmail.com>2020-01-11 09:54:48 -0500
commit27c93abd49ca8a519d2aa3cf7938434fe25947d7 (patch)
tree14f137aa8332ef1ce0cf95ff5cde52246637d45f /src/server/DashSession/DashSessionAgent.ts
parent7a20f573f4f428bfc779797d437fa9525b6976f8 (diff)
extends message, removed duplicate handlers, IPC streamlined
Diffstat (limited to 'src/server/DashSession/DashSessionAgent.ts')
-rw-r--r--src/server/DashSession/DashSessionAgent.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts
index 0d9486757..b7e741525 100644
--- a/src/server/DashSession/DashSessionAgent.ts
+++ b/src/server/DashSession/DashSessionAgent.ts
@@ -11,6 +11,7 @@ import { resolve } from "path";
import { AppliedSessionAgent, ExitHandler } from "../session/agents/applied_session_agent";
import { Monitor } from "../session/agents/monitor";
import { ServerWorker } from "../session/agents/server_worker";
+import { Message } from "../session/utilities/ipc";
/**
* If we're the monitor (master) thread, we should launch the monitor logic for the session.
@@ -26,14 +27,14 @@ export class DashSessionAgent extends AppliedSessionAgent {
* The core method invoked when the single master thread is initialized.
* Installs event hooks, repl commands and additional IPC listeners.
*/
- protected async initializeMonitor(monitor: Monitor) {
+ protected async initializeMonitor(monitor: Monitor, sessionKey: string) {
+ await this.dispatchSessionPassword(sessionKey);
monitor.addReplCommand("pull", [], () => monitor.exec("git pull"));
monitor.addReplCommand("solr", [/start|stop|index/], this.executeSolrCommand);
monitor.addReplCommand("backup", [], this.backup);
monitor.addReplCommand("debug", [/active|passive/, /\S+\@\S+/], async ([mode, recipient]) => this.dispatchZippedDebugBackup(mode, recipient));
- monitor.addServerMessageListener("backup", this.backup);
- monitor.addServerMessageListener("debug", ({ args: { mode, recipient } }) => this.dispatchZippedDebugBackup(mode, recipient));
- monitor.onKeyGenerated(this.dispatchSessionPassword);
+ monitor.addMessageListener("backup", this.backup);
+ monitor.addMessageListener("debug", ({ args: { mode, recipient } }) => this.dispatchZippedDebugBackup(mode, recipient));
monitor.onCrashDetected(this.dispatchCrashReport);
}
@@ -80,14 +81,14 @@ export class DashSessionAgent extends AppliedSessionAgent {
* This sends a pseudorandomly generated guid to the configuration's recipients, allowing them alone
* to kill the server via the /kill/:key route.
*/
- private dispatchSessionPassword = async (key: string) => {
+ private dispatchSessionPassword = async (sessionKey: string) => {
const { mainLog } = this.sessionMonitor;
const { notificationRecipient } = DashSessionAgent;
mainLog(green("dispatching session key..."));
const error = await Email.dispatch({
to: notificationRecipient,
subject: "Dash Release Session Admin Authentication Key",
- content: `The key for this session (started @ ${new Date().toUTCString()}) is ${key}.\n\n${this.signature}`
+ content: `The key for this session (started @ ${new Date().toUTCString()}) is ${sessionKey}.\n\n${this.signature}`
});
if (error) {
this.sessionMonitor.mainLog(red(`dispatch failure @ ${notificationRecipient} (${yellow(error.message)})`));
@@ -100,7 +101,7 @@ export class DashSessionAgent extends AppliedSessionAgent {
/**
* This sends an email with the generated crash report.
*/
- private dispatchCrashReport = async (crashCause: Error) => {
+ private dispatchCrashReport = async ({ args: { error: crashCause } }: Message) => {
const { mainLog } = this.sessionMonitor;
const { notificationRecipient } = DashSessionAgent;
const error = await Email.dispatch({