From ef5eb24af4a1584a7eaad704b809639cfb64770a Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Wed, 17 May 2023 16:57:56 +0000 Subject: [PATCH] alias `comty.js` lib --- packages/marketplace_server/src/index.js | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/marketplace_server/src/index.js b/packages/marketplace_server/src/index.js index acb48ba9..a832be27 100644 --- a/packages/marketplace_server/src/index.js +++ b/packages/marketplace_server/src/index.js @@ -5,6 +5,7 @@ import { registerBaseAliases } from "linebridge/dist/server" registerBaseAliases(undefined, { "@services": path.resolve(__dirname, "services"), + "comty.js": path.resolve(__dirname, "../../comty.js/src"), }) // patches @@ -46,9 +47,35 @@ global.isProduction = process.env.NODE_ENV === "production" import API from "./api" async function main() { - const mainAPI = new API() + const instance = new API() - await mainAPI.initialize() + await instance.initialize() + + // kill on process exit + process.on("exit", () => { + instance.server.close() + process.exit(0) + }) + + // kill on ctrl+c + process.on("SIGINT", () => { + instance.server.close() + process.exit(0) + }) + + // kill on uncaught exceptions + process.on("uncaughtException", (error) => { + console.error(`🆘 [FATAL ERROR] >`, error) + instance.server.close() + process.exit(1) + }) + + // kill on unhandled rejections + process.on("unhandledRejection", (error) => { + console.error(`🆘 [FATAL ERROR] >`, error) + instance.server.close() + process.exit(1) + }) } main().catch((error) => {