fixed browser, made payload optional
This commit is contained in:
parent
917f91715a
commit
cde67db271
9 changed files with 10 additions and 12 deletions
|
|
@ -13,7 +13,6 @@ import { ProxyManager } from '@stock-bot/utils';
|
||||||
import { exchangeRoutes, healthRoutes, queueRoutes } from './routes';
|
import { exchangeRoutes, healthRoutes, queueRoutes } from './routes';
|
||||||
|
|
||||||
const config = initializeConfig();
|
const config = initializeConfig();
|
||||||
console.log('Configuration loaded:', config);
|
|
||||||
const serviceConfig = config.service;
|
const serviceConfig = config.service;
|
||||||
const databaseConfig = config.database;
|
const databaseConfig = config.database;
|
||||||
const queueConfig = config.queue;
|
const queueConfig = config.queue;
|
||||||
|
|
@ -252,7 +251,7 @@ shutdown.onShutdown(async () => {
|
||||||
logger.info('Shutting down loggers...');
|
logger.info('Shutting down loggers...');
|
||||||
await shutdownLoggers();
|
await shutdownLoggers();
|
||||||
// Don't log after shutdown
|
// Don't log after shutdown
|
||||||
} catch (error) {
|
} catch {
|
||||||
// Silently ignore logger shutdown errors
|
// Silently ignore logger shutdown errors
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ export function initializeExchangeSyncProvider() {
|
||||||
{
|
{
|
||||||
type: 'exchange-sync-daily',
|
type: 'exchange-sync-daily',
|
||||||
operation: 'sync-ib-exchanges',
|
operation: 'sync-ib-exchanges',
|
||||||
payload: {},
|
|
||||||
cronPattern: '0 3 * * *', // Daily at 3 AM
|
cronPattern: '0 3 * * *', // Daily at 3 AM
|
||||||
priority: 3,
|
priority: 3,
|
||||||
description: 'Daily sync of IB exchanges to master table',
|
description: 'Daily sync of IB exchanges to master table',
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ export function initializeIBProvider() {
|
||||||
{
|
{
|
||||||
type: 'ib-exchanges-and-symbols',
|
type: 'ib-exchanges-and-symbols',
|
||||||
operation: 'ib-exchanges-and-symbols',
|
operation: 'ib-exchanges-and-symbols',
|
||||||
payload: {},
|
|
||||||
cronPattern: '0 0 * * 0', // Every Sunday at midnight
|
cronPattern: '0 0 * * 0', // Every Sunday at midnight
|
||||||
priority: 5,
|
priority: 5,
|
||||||
description: 'Fetch and update IB exchanges and symbols data',
|
description: 'Fetch and update IB exchanges and symbols data',
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@ export function initializeProxyProvider() {
|
||||||
{
|
{
|
||||||
type: 'proxy-fetch-and-check',
|
type: 'proxy-fetch-and-check',
|
||||||
operation: 'fetch-from-sources',
|
operation: 'fetch-from-sources',
|
||||||
payload: {},
|
|
||||||
cronPattern: '0 0 * * 0', // Every week at midnight on Sunday
|
cronPattern: '0 0 * * 0', // Every week at midnight on Sunday
|
||||||
priority: 0,
|
priority: 0,
|
||||||
description: 'Fetch and validate proxy list from sources',
|
description: 'Fetch and validate proxy list from sources',
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ export function initializeQMProvider() {
|
||||||
{
|
{
|
||||||
type: 'session-management',
|
type: 'session-management',
|
||||||
operation: 'create-sessions',
|
operation: 'create-sessions',
|
||||||
payload: {},
|
|
||||||
cronPattern: '*/15 * * * * *', // Every minute
|
cronPattern: '*/15 * * * * *', // Every minute
|
||||||
priority: 7,
|
priority: 7,
|
||||||
immediately: true,
|
immediately: true,
|
||||||
|
|
@ -71,7 +70,6 @@ export function initializeQMProvider() {
|
||||||
{
|
{
|
||||||
type: 'qm-maintnance',
|
type: 'qm-maintnance',
|
||||||
operation: 'spider-symbol-search',
|
operation: 'spider-symbol-search',
|
||||||
payload: {},
|
|
||||||
cronPattern: '0 0 * * 0', // Every minute
|
cronPattern: '0 0 * * 0', // Every minute
|
||||||
priority: 10,
|
priority: 10,
|
||||||
description: 'Comprehensive symbol search using QM API',
|
description: 'Comprehensive symbol search using QM API',
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ export function initializeWebShareProvider() {
|
||||||
{
|
{
|
||||||
type: 'webshare-fetch',
|
type: 'webshare-fetch',
|
||||||
operation: 'fetch-proxies',
|
operation: 'fetch-proxies',
|
||||||
payload: {},
|
|
||||||
cronPattern: '0 */6 * * *', // Every 6 hours
|
cronPattern: '0 */6 * * *', // Every 6 hours
|
||||||
priority: 3,
|
priority: 3,
|
||||||
description: 'Fetch fresh proxies from WebShare API',
|
description: 'Fetch fresh proxies from WebShare API',
|
||||||
|
|
|
||||||
|
|
@ -171,10 +171,15 @@ class BrowserSingleton {
|
||||||
|
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
const [protocol, rest] = proxy.split('://');
|
const [protocol, rest] = proxy.split('://');
|
||||||
|
if (!rest) {
|
||||||
|
throw new Error('Invalid proxy format. Expected protocol://host:port or protocol://user:pass@host:port');
|
||||||
|
}
|
||||||
|
|
||||||
const [auth, hostPort] = rest.includes('@') ? rest.split('@') : [null, rest];
|
const [auth, hostPort] = rest.includes('@') ? rest.split('@') : [null, rest];
|
||||||
const [host, port] = hostPort.split(':');
|
const finalHostPort = hostPort || rest;
|
||||||
|
const [host, port] = finalHostPort.split(':');
|
||||||
|
|
||||||
contextOptions.proxy = {
|
contextOptions['proxy'] = {
|
||||||
server: `${protocol}://${host}:${port}`,
|
server: `${protocol}://${host}:${port}`,
|
||||||
username: auth?.split(':')[0] || '',
|
username: auth?.split(':')[0] || '',
|
||||||
password: auth?.split(':')[1] || '',
|
password: auth?.split(':')[1] || '',
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ export function createJobHandler<TPayload = unknown, TResult = unknown>(
|
||||||
export interface ScheduledJob<T = unknown> {
|
export interface ScheduledJob<T = unknown> {
|
||||||
type: string;
|
type: string;
|
||||||
operation: string;
|
operation: string;
|
||||||
payload: T;
|
payload?: T;
|
||||||
cronPattern: string;
|
cronPattern: string;
|
||||||
priority?: number;
|
priority?: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ async function testProxyBrowser() {
|
||||||
console.error('❌ Proxy browser test failed:', { error });
|
console.error('❌ Proxy browser test failed:', { error });
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
// await Browser.cleanup();
|
await Browser.close();
|
||||||
console.log('🧹 Browser cleanup completed');
|
console.log('🧹 Browser cleanup completed');
|
||||||
} catch (cleanupError) {
|
} catch (cleanupError) {
|
||||||
console.error('Failed to cleanup browser:', { error: cleanupError });
|
console.error('Failed to cleanup browser:', { error: cleanupError });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue