work on postgress / will prob remove and work on ib exchanges and symbols
This commit is contained in:
parent
cce5126cb7
commit
a20a11c1aa
16 changed files with 1441 additions and 95 deletions
|
|
@ -4,7 +4,7 @@
|
|||
import { Hono } from 'hono';
|
||||
import { Browser } from '@stock-bot/browser';
|
||||
import { loadEnvVariables } from '@stock-bot/config';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { getLogger, shutdownLoggers } from '@stock-bot/logger';
|
||||
import { Shutdown } from '@stock-bot/shutdown';
|
||||
import { initializeIBResources } from './providers/ib.tasks';
|
||||
import { initializeProxyResources } from './providers/proxy.tasks';
|
||||
|
|
@ -99,7 +99,38 @@ shutdown.onShutdown(async () => {
|
|||
logger.info('Queue manager shut down successfully');
|
||||
} catch (error) {
|
||||
logger.error('Error shutting down queue manager', { error });
|
||||
throw error; // Re-throw to mark shutdown as failed
|
||||
// Don't re-throw to allow other shutdown handlers to complete
|
||||
// The shutdown library tracks failures internally
|
||||
}
|
||||
});
|
||||
|
||||
// Add Browser shutdown handler
|
||||
shutdown.onShutdown(async () => {
|
||||
logger.info('Shutting down browser resources...');
|
||||
try {
|
||||
await Browser.close();
|
||||
logger.info('Browser resources shut down successfully');
|
||||
} catch (error) {
|
||||
// Browser might already be closed by running tasks, this is expected
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
if (errorMessage.includes('Target page, context or browser has been closed')) {
|
||||
logger.info('Browser was already closed by running tasks');
|
||||
} else {
|
||||
logger.error('Error shutting down browser resources', { error });
|
||||
}
|
||||
// Don't throw here as browser shutdown shouldn't block app shutdown
|
||||
}
|
||||
});
|
||||
|
||||
// Add logger shutdown handler (should be last)
|
||||
shutdown.onShutdown(async () => {
|
||||
try {
|
||||
await shutdownLoggers();
|
||||
// Use process.stdout since loggers are being shut down
|
||||
process.stdout.write('All loggers flushed and shut down successfully\n');
|
||||
} catch (error) {
|
||||
process.stderr.write(`Error shutting down loggers: ${error}\n`);
|
||||
// Don't throw here as this is the final cleanup
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue