feat(queue): add typed application queue lifecycle
This commit is contained in:
1 parent
9332522614
commit
9377a69d88
17 files changed
+667
-13
No files matched your search
@@ -79,6 +79,8 @@ export interface ProdManifest {
|
||||
layouts: { name: string; mod: RouteModule }[];
|
||||
/** RPC service implementations (from app/services/*.ts). */
|
||||
services?: { name: string; mod: RouteModule }[];
|
||||
/** Background queue modules (from app/queues/*.ts). */
|
||||
queues?: { name: string; mod: RouteModule }[];
|
||||
}
|
||||
|
||||
export interface ProductionPluginAsset {
|
||||
@@ -292,6 +294,7 @@ function buildProdRouter(manifest: ProdManifest): {
|
||||
for (const l of manifest.layouts) modules.set(`layout:${l.name}`, l.mod);
|
||||
for (const service of manifest.services ?? [])
|
||||
modules.set(`service:${service.name}`, service.mod);
|
||||
for (const queue of manifest.queues ?? []) modules.set(`queue:${queue.name}`, queue.mod);
|
||||
|
||||
const router: Router = {
|
||||
pages,
|
||||
@@ -307,6 +310,10 @@ function buildProdRouter(manifest: ProdManifest): {
|
||||
name: service.name,
|
||||
file: `service:${service.name}`,
|
||||
})),
|
||||
queues: (manifest.queues ?? []).map((queue) => ({
|
||||
name: queue.name,
|
||||
file: `queue:${queue.name}`,
|
||||
})),
|
||||
matchPage: optimizedMatcher(pages),
|
||||
matchApi: optimizedMatcher(api),
|
||||
matchRealtime: optimizedMatcher(realtime),
|
||||
@@ -652,11 +659,12 @@ export async function createProductionServer(manifest: ProdManifest, opts: ProdO
|
||||
|
||||
// Graceful shutdown: stop accepting connections, then exit.
|
||||
let shuttingDown = false;
|
||||
const shutdown = () => {
|
||||
const shutdown = async () => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
console.log("WrNexus: shutting down…");
|
||||
server.stop();
|
||||
await handlers.shutdown();
|
||||
process.exit(0);
|
||||
};
|
||||
process.on("SIGTERM", shutdown);
|
||||
|
||||
Reference in new issue
Block a user