cleaned up index
This commit is contained in:
parent
b49bea818b
commit
df611a3ce3
1 changed files with 19 additions and 29 deletions
|
|
@ -19,8 +19,8 @@ loadEnvVariables();
|
|||
|
||||
const app = new Hono();
|
||||
const logger = getLogger('data-service');
|
||||
|
||||
const PORT = parseInt(process.env.DATA_SERVICE_PORT || '3002');
|
||||
let server: any = null;
|
||||
|
||||
// Register all routes
|
||||
app.route('', healthRoutes);
|
||||
|
|
@ -47,27 +47,18 @@ async function initializeServices() {
|
|||
}
|
||||
|
||||
// Start server
|
||||
let server: any = null;
|
||||
|
||||
async function startServer() {
|
||||
await initializeServices();
|
||||
|
||||
// Start the HTTP server using Bun's native serve
|
||||
server = Bun.serve({
|
||||
port: PORT,
|
||||
fetch: app.fetch,
|
||||
development: process.env.NODE_ENV === 'development',
|
||||
});
|
||||
|
||||
logger.info(`Data Service started on port ${PORT}`);
|
||||
|
||||
// Register shutdown callbacks
|
||||
setupShutdownHandlers();
|
||||
}
|
||||
|
||||
// Setup shutdown handlers using the shutdown library
|
||||
function setupShutdownHandlers() {
|
||||
// Set shutdown timeout to 15 seconds
|
||||
// Setup shutdown handling
|
||||
setShutdownTimeout(15000);
|
||||
|
||||
// Register cleanup for HTTP server
|
||||
|
|
@ -84,10 +75,9 @@ function setupShutdownHandlers() {
|
|||
await queueManager.shutdown();
|
||||
});
|
||||
|
||||
logger.info('Shutdown handlers registered');
|
||||
}
|
||||
|
||||
startServer().catch(error => {
|
||||
logger.error('Failed to start server', { error });
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
logger.info('Shutdown handlers registered');
|
||||
Loading…
Add table
Add a link
Reference in a new issue