From 804e2f4f1d20551799a21e2fdf8e5b2b7fdebe02 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 4 Jan 2020 12:02:45 -0800 Subject: final touches --- src/server/index.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/server/index.ts b/src/server/index.ts index 4dabf612d..3c1839e4d 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -27,14 +27,6 @@ import { Session } from "./Session/session"; import { isMaster } from "cluster"; import { execSync } from "child_process"; -if (isMaster) { - Session.initializeMaster().then(({ registerCommand }) => { - registerCommand("pull", [], () => execSync("git pull", { stdio: ["ignore", "inherit", "inherit"] })); - }); -} else { - Session.initializeWorker(launch); -} - export const publicDirectory = path.resolve(__dirname, "public"); export const filesDirectory = path.resolve(publicDirectory, "files"); @@ -136,11 +128,20 @@ function routeSetter({ isRelease, addSupervisedRoute, logRegistrationOutcome }: WebSocket.initialize(serverPort, isRelease); } -async function launch() { - await log_execution({ - startMessage: "\nstarting execution of preliminary functions", - endMessage: "completed preliminary functions\n", - action: preliminaryFunctions +/** + * Thread dependent session initialization + */ +if (isMaster) { + Session.initializeMaster().then(({ registerCommand }) => { + registerCommand("pull", [], () => execSync("git pull", { stdio: ["ignore", "inherit", "inherit"] })); + }); +} else { + Session.initializeWorker(async () => { + await log_execution({ + startMessage: "\nstarting execution of preliminary functions", + endMessage: "completed preliminary functions\n", + action: preliminaryFunctions + }); + await initializeServer({ serverPort: 1050, routeSetter }); }); - await initializeServer({ serverPort: 1050, routeSetter }); } \ No newline at end of file -- cgit v1.2.3-70-g09d2