Retry incomplete controller startup (Refs #65)
This commit is contained in:
+10
-7
@@ -9,21 +9,24 @@ import { withOperationSource } from '$lib/server/hosts/operation-context.js';
|
||||
import { withHostRequestContext } from '$lib/server/hosts/request-context.js';
|
||||
|
||||
let booted = false;
|
||||
let rejectionLoggerRegistered = false;
|
||||
function boot(): void {
|
||||
if (booted) return;
|
||||
booted = true;
|
||||
process.on('unhandledRejection', reason => {
|
||||
console.error('[process] unhandled rejection:', reason);
|
||||
});
|
||||
if (!rejectionLoggerRegistered) {
|
||||
process.on('unhandledRejection', reason => {
|
||||
console.error('[process] unhandled rejection:', reason);
|
||||
});
|
||||
rejectionLoggerRegistered = true;
|
||||
}
|
||||
migrate();
|
||||
interruptDeployments();
|
||||
startWorker();
|
||||
startPerformanceMonitor();
|
||||
booted = true;
|
||||
}
|
||||
|
||||
// SvelteKit calls handle() for every request; using the first request as the
|
||||
// boot trigger keeps the whole app single-process without needing an
|
||||
// out-of-band init hook.
|
||||
// Boot synchronously before serving requests. Failed startup stays unbooted so
|
||||
// the next request retries migrations and worker startup before reaching the UI.
|
||||
export const handle: Handle = async (input) => {
|
||||
boot();
|
||||
const started = performance.now();
|
||||
|
||||
Reference in New Issue
Block a user