fix: emergency automation fix - stop runaway trading loops
- Replace automation service with emergency rate-limited version - Add 5-minute minimum interval between automation starts - Implement forced Chromium process cleanup on stop - Backup broken automation service as .broken file - Emergency service prevents multiple simultaneous automations - Fixed 1400+ Chromium process accumulation issue - Tested and confirmed: rate limiting works, processes stay at 0
This commit is contained in:
@@ -54,6 +54,7 @@ export class EnhancedScreenshotService {
|
||||
}
|
||||
|
||||
// Create parallel session promises for true dual-session approach
|
||||
const activeSessions: TradingViewAutomation[] = []
|
||||
const sessionPromises = layoutsToCapture.map(async (layout, index) => {
|
||||
const layoutKey = layout.toLowerCase()
|
||||
let layoutSession: TradingViewAutomation | null = null
|
||||
@@ -77,6 +78,7 @@ export class EnhancedScreenshotService {
|
||||
|
||||
// Create a dedicated automation instance for this layout
|
||||
layoutSession = new TradingViewAutomation()
|
||||
activeSessions.push(layoutSession) // Track for cleanup
|
||||
|
||||
console.log(`🐳 Starting ${layout} browser session...`)
|
||||
await layoutSession.init()
|
||||
@@ -261,6 +263,20 @@ export class EnhancedScreenshotService {
|
||||
console.log(`\n⚡ Executing ${layoutsToCapture.length} sessions in parallel...`)
|
||||
const results = await Promise.allSettled(sessionPromises)
|
||||
|
||||
// Cleanup all sessions after capture (success or failure)
|
||||
console.log('🧹 Cleaning up all browser sessions...')
|
||||
await Promise.allSettled(
|
||||
activeSessions.map(async (session, index) => {
|
||||
try {
|
||||
const layout = layoutsToCapture[index]
|
||||
console.log(`🧹 Cleaning up ${layout} session...`)
|
||||
await session.forceCleanup()
|
||||
} catch (cleanupError) {
|
||||
console.warn(`⚠️ Cleanup failed for session ${index}:`, cleanupError)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// Collect successful screenshots
|
||||
results.forEach((result, index) => {
|
||||
const layout = layoutsToCapture[index]
|
||||
|
||||
Reference in New Issue
Block a user