aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index 6099af83c..3764eaabb 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -18,10 +18,10 @@ import { GoogleCredentialsLoader } from './credentials/CredentialsLoader';
import DeleteManager from "./ApiManagers/DeleteManager";
import PDFManager from "./ApiManagers/PDFManager";
import UploadManager from "./ApiManagers/UploadManager";
-import { log_execution } from "./ActionUtilities";
+import { log_execution, command_line } from "./ActionUtilities";
import GeneralGoogleManager from "./ApiManagers/GeneralGoogleManager";
import GooglePhotosManager from "./ApiManagers/GooglePhotosManager";
-import { yellow } from "colors";
+import { yellow, red } from "colors";
import { disconnect } from "../server/Initialization";
export const publicDirectory = path.resolve(__dirname, "public");
@@ -119,6 +119,31 @@ function routeSetter({ isRelease, addSupervisedRoute, logRegistrationOutcome }:
}
});
+ let daemonInitialized = false;
+ addSupervisedRoute({
+ method: Method.GET,
+ subscription: "/persist",
+ onValidation: async ({ res }) => {
+ if (!daemonInitialized) {
+ daemonInitialized = true;
+ log_execution({
+ startMessage: "\ninitializing persistence daemon",
+ endMessage: ({ result, error }) => {
+ const success = error === null && result !== undefined;
+ if (!success) {
+ console.log(red("failed to initialize the persistance daemon"));
+ process.exit(0);
+ }
+ return "persistence daemon process closed";
+ },
+ action: async () => command_line("npx ts-node ./persistence_daemon.ts", "./src/server"),
+ color: yellow
+ });
+ }
+ res.redirect("/home");
+ }
+ });
+
logRegistrationOutcome();
// initialize the web socket (bidirectional communication: if a user changes