mirror of
https://github.com/LukeHagar/pypistats.dev.git
synced 2025-12-06 04:21:09 +00:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { closeRedisClient, forceDisconnectRedis } from '$lib/redis.js';
|
|
import type { Handle } from '@sveltejs/kit';
|
|
|
|
// Minimal server hooks without cron
|
|
if (typeof process !== 'undefined') {
|
|
// Graceful shutdown
|
|
process.on('SIGTERM', async () => {
|
|
console.log('🛑 Received SIGTERM, closing connections...');
|
|
await closeRedisClient();
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('SIGINT', async () => {
|
|
console.log('🛑 Received SIGINT, closing connections...');
|
|
await closeRedisClient();
|
|
process.exit(0);
|
|
});
|
|
|
|
// Handle uncaught exceptions
|
|
process.on('uncaughtException', async (error) => {
|
|
console.error('🛑 Uncaught Exception:', error);
|
|
await forceDisconnectRedis();
|
|
process.exit(1);
|
|
});
|
|
|
|
process.on('unhandledRejection', async (reason, promise) => {
|
|
console.error('🛑 Unhandled Rejection at:', promise, 'reason:', reason);
|
|
await forceDisconnectRedis();
|
|
process.exit(1);
|
|
});
|
|
}
|
|
|
|
export const handle: Handle = async ({ event, resolve }) => {
|
|
return resolve(event);
|
|
}; |