aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-12-08 22:32:31 -0500
committerBob Zeleznik <zzzman@gmail.com>2019-12-08 22:32:31 -0500
commitcfaf02757f5aebd2ccce0bbef8b6f5e232932693 (patch)
tree021efc9779dc329e4e9ba94ac74eb6ef7e9dcb20 /src/server/index.ts
parent6c28c3f00e5072b75a5d38da49a234cf347c6605 (diff)
parentc3e0c3e7faf374a0d1b75c77d4f40abd7aec3a1f (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index 42b4f7ff2..6099af83c 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -22,6 +22,7 @@ import { log_execution } from "./ActionUtilities";
import GeneralGoogleManager from "./ApiManagers/GeneralGoogleManager";
import GooglePhotosManager from "./ApiManagers/GooglePhotosManager";
import { yellow } from "colors";
+import { disconnect } from "../server/Initialization";
export const publicDirectory = path.resolve(__dirname, "public");
export const filesDirectory = path.resolve(publicDirectory, "files");
@@ -34,35 +35,6 @@ export const ExitHandlers = new Array<() => void>();
* before clients can access the server should be run or awaited here.
*/
async function preliminaryFunctions() {
- process.on('SIGINT', () => {
- const { stdin, stdout, stderr } = process;
- stdin.resume();
- stdout.resume();
- stderr.resume();
- ExitHandlers.forEach(handler => handler());
- console.log("Okay, now we're done...");
- // process.exit(0);
- });
-
- (process as any).on('cleanup', () => {
- console.log("CLEANING UP!");
- });
-
- process.on('exit', function () {
- (process.emit as Function)('cleanup');
- });
-
- //catch uncaught exceptions, trace, then exit normally
- process.on('uncaughtException', function (e) {
- console.log('Uncaught Exception...');
- process.exit(99);
- });
- process.on('unhandledRejection', function (e) {
- console.log('Unhandled Rejection...');
- process.exit(99);
- });
-
- await SolrManager.initializeSolr();
await GoogleCredentialsLoader.loadCredentials();
GoogleApiServerUtils.processProjectCredentials();
await DashUploadUtils.buildFileDirectories();
@@ -114,6 +86,19 @@ function routeSetter({ isRelease, addSupervisedRoute, logRegistrationOutcome }:
onValidation: ({ res }) => res.send(true)
});
+ addSupervisedRoute({
+ method: Method.GET,
+ subscription: "/shutdown",
+ onValidation: async ({ res }) => {
+ WebSocket.disconnect();
+ await disconnect();
+ await Database.disconnect();
+ SolrManager.SetRunning(false);
+ res.send("Server successfully shut down.");
+ process.exit(0);
+ }
+ });
+
const serve: OnUnauthenticated = ({ req, res }) => {
const detector = new mobileDetect(req.headers['user-agent'] || "");
const filename = detector.mobile() !== null ? 'mobile/image.html' : 'index.html';