fixed format issues
This commit is contained in:
parent
a700818a06
commit
08f713d98b
55 changed files with 5680 additions and 5533 deletions
|
|
@ -1,3 +1,3 @@
|
|||
// Export only what's actually used
|
||||
export { ServiceApplication } from './service-application';
|
||||
export { ServiceContainerBuilder } from './container/builder';
|
||||
export { ServiceContainerBuilder } from './container/builder';
|
||||
|
|
|
|||
|
|
@ -166,82 +166,102 @@ export class ServiceApplication {
|
|||
private registerShutdownHandlers(): void {
|
||||
// Priority 1: Queue system (highest priority)
|
||||
if (this.serviceConfig.enableScheduledJobs) {
|
||||
this.shutdown.onShutdown(async () => {
|
||||
this.logger.info('Shutting down queue system...');
|
||||
try {
|
||||
const queueManager = this.container?.resolve('queueManager');
|
||||
if (queueManager) {
|
||||
await queueManager.shutdown();
|
||||
this.shutdown.onShutdown(
|
||||
async () => {
|
||||
this.logger.info('Shutting down queue system...');
|
||||
try {
|
||||
const queueManager = this.container?.resolve('queueManager');
|
||||
if (queueManager) {
|
||||
await queueManager.shutdown();
|
||||
}
|
||||
this.logger.info('Queue system shut down');
|
||||
} catch (error) {
|
||||
this.logger.error('Error shutting down queue system', { error });
|
||||
}
|
||||
this.logger.info('Queue system shut down');
|
||||
} catch (error) {
|
||||
this.logger.error('Error shutting down queue system', { error });
|
||||
}
|
||||
}, SHUTDOWN_DEFAULTS.HIGH_PRIORITY, 'Queue System');
|
||||
},
|
||||
SHUTDOWN_DEFAULTS.HIGH_PRIORITY,
|
||||
'Queue System'
|
||||
);
|
||||
}
|
||||
|
||||
// Priority 1: HTTP Server (high priority)
|
||||
this.shutdown.onShutdown(async () => {
|
||||
if (this.server) {
|
||||
this.logger.info('Stopping HTTP server...');
|
||||
try {
|
||||
this.server.stop();
|
||||
this.logger.info('HTTP server stopped');
|
||||
} catch (error) {
|
||||
this.logger.error('Error stopping HTTP server', { error });
|
||||
this.shutdown.onShutdown(
|
||||
async () => {
|
||||
if (this.server) {
|
||||
this.logger.info('Stopping HTTP server...');
|
||||
try {
|
||||
this.server.stop();
|
||||
this.logger.info('HTTP server stopped');
|
||||
} catch (error) {
|
||||
this.logger.error('Error stopping HTTP server', { error });
|
||||
}
|
||||
}
|
||||
}
|
||||
}, SHUTDOWN_DEFAULTS.HIGH_PRIORITY, 'HTTP Server');
|
||||
},
|
||||
SHUTDOWN_DEFAULTS.HIGH_PRIORITY,
|
||||
'HTTP Server'
|
||||
);
|
||||
|
||||
// Custom shutdown hook
|
||||
if (this.hooks.onBeforeShutdown) {
|
||||
this.shutdown.onShutdown(async () => {
|
||||
try {
|
||||
await this.hooks.onBeforeShutdown!();
|
||||
} catch (error) {
|
||||
this.logger.error('Error in custom shutdown hook', { error });
|
||||
}
|
||||
}, SHUTDOWN_DEFAULTS.HIGH_PRIORITY, 'Custom Shutdown');
|
||||
this.shutdown.onShutdown(
|
||||
async () => {
|
||||
try {
|
||||
await this.hooks.onBeforeShutdown!();
|
||||
} catch (error) {
|
||||
this.logger.error('Error in custom shutdown hook', { error });
|
||||
}
|
||||
},
|
||||
SHUTDOWN_DEFAULTS.HIGH_PRIORITY,
|
||||
'Custom Shutdown'
|
||||
);
|
||||
}
|
||||
|
||||
// Priority 2: Services and connections (medium priority)
|
||||
this.shutdown.onShutdown(async () => {
|
||||
this.logger.info('Disposing services and connections...');
|
||||
try {
|
||||
if (this.container) {
|
||||
// Disconnect database clients
|
||||
const mongoClient = this.container.resolve('mongoClient');
|
||||
if (mongoClient?.disconnect) {
|
||||
await mongoClient.disconnect();
|
||||
}
|
||||
this.shutdown.onShutdown(
|
||||
async () => {
|
||||
this.logger.info('Disposing services and connections...');
|
||||
try {
|
||||
if (this.container) {
|
||||
// Disconnect database clients
|
||||
const mongoClient = this.container.resolve('mongoClient');
|
||||
if (mongoClient?.disconnect) {
|
||||
await mongoClient.disconnect();
|
||||
}
|
||||
|
||||
const postgresClient = this.container.resolve('postgresClient');
|
||||
if (postgresClient?.disconnect) {
|
||||
await postgresClient.disconnect();
|
||||
}
|
||||
const postgresClient = this.container.resolve('postgresClient');
|
||||
if (postgresClient?.disconnect) {
|
||||
await postgresClient.disconnect();
|
||||
}
|
||||
|
||||
const questdbClient = this.container.resolve('questdbClient');
|
||||
if (questdbClient?.disconnect) {
|
||||
await questdbClient.disconnect();
|
||||
}
|
||||
const questdbClient = this.container.resolve('questdbClient');
|
||||
if (questdbClient?.disconnect) {
|
||||
await questdbClient.disconnect();
|
||||
}
|
||||
|
||||
this.logger.info('All services disposed successfully');
|
||||
this.logger.info('All services disposed successfully');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error('Error disposing services', { error });
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error('Error disposing services', { error });
|
||||
}
|
||||
}, SHUTDOWN_DEFAULTS.MEDIUM_PRIORITY, 'Services');
|
||||
},
|
||||
SHUTDOWN_DEFAULTS.MEDIUM_PRIORITY,
|
||||
'Services'
|
||||
);
|
||||
|
||||
// Priority 3: Logger shutdown (lowest priority - runs last)
|
||||
this.shutdown.onShutdown(async () => {
|
||||
try {
|
||||
this.logger.info('Shutting down loggers...');
|
||||
await shutdownLoggers();
|
||||
// Don't log after shutdown
|
||||
} catch {
|
||||
// Silently ignore logger shutdown errors
|
||||
}
|
||||
}, SHUTDOWN_DEFAULTS.LOW_PRIORITY, 'Loggers');
|
||||
this.shutdown.onShutdown(
|
||||
async () => {
|
||||
try {
|
||||
this.logger.info('Shutting down loggers...');
|
||||
await shutdownLoggers();
|
||||
// Don't log after shutdown
|
||||
} catch {
|
||||
// Silently ignore logger shutdown errors
|
||||
}
|
||||
},
|
||||
SHUTDOWN_DEFAULTS.LOW_PRIORITY,
|
||||
'Loggers'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue