mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-09 02:01:48 +00:00
Process lifecycle scripts
#Conflicts: # src/api/Server.ts # src/bundle/Server.ts # src/cdn/Server.ts # src/gateway/Server.ts # src/gateway/events/Connection.ts # src/util/util/ipc/listener/RabbitMqSingleListener.ts # src/util/util/ipc/listener/UnixSocketListener.ts # src/util/util/ipc/writer/UnixSocketWriter.ts # src/webrtc/Server.ts
This commit is contained in:
+7
-5
@@ -16,15 +16,16 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import path from "node:path";
|
||||
import { Request, Response, Router } from "express";
|
||||
import morgan from "morgan";
|
||||
import { Server, ServerOptions } from "lambert-server";
|
||||
import { red } from "picocolors";
|
||||
import { Config, ConnectionConfig, ConnectionLoader, Email, JSONReplacer, WebAuthn, initDatabase, initEvent, registerRoutes, getDatabase, getRevInfoOrFail } from "@spacebar/util";
|
||||
import { Authentication, CORS, ImageProxy, BodyParser, ErrorHandler, initRateLimits, initTranslation } from "./middlewares";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Server, ServerOptions } from "lambert-server";
|
||||
import morgan from "morgan";
|
||||
import path from "node:path";
|
||||
import { red } from "picocolors";
|
||||
import { initInstance } from "./util/handlers/Instance";
|
||||
import { route } from "./util";
|
||||
import { ProcessLifecycle } from "../util/util/ProcessLifecycle";
|
||||
|
||||
const ASSETS_FOLDER = path.join(__dirname, "..", "..", "assets");
|
||||
const PUBLIC_ASSETS_FOLDER = path.join(ASSETS_FOLDER, "public");
|
||||
@@ -196,6 +197,7 @@ export class SpacebarServer extends Server {
|
||||
|
||||
if (logRequests) console.log(red(`Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`));
|
||||
|
||||
await ProcessLifecycle.Ready();
|
||||
return super.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { route, SpacebarServer } from "@spacebar/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { ProcessLifecycle } from "../../util/util/ProcessLifecycle";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
@@ -35,7 +36,9 @@ router.post(
|
||||
(req: Request, res: Response) => {
|
||||
console.log(`/stop was called by ${req.user_id} at ${new Date()}`);
|
||||
res.sendStatus(200);
|
||||
process.kill(process.pid, "SIGTERM");
|
||||
ProcessLifecycle.Shutdown().catch((e) => {
|
||||
console.error("Failed to shut down:", e);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user