fix: Database-first cluster status detection + Stop button clarification

CRITICAL FIX (Nov 30, 2025):
- Dashboard showed 'idle' despite 22+ worker processes running
- Root cause: SSH-based worker detection timing out
- Solution: Check database for running chunks FIRST

Changes:
1. app/api/cluster/status/route.ts:
   - Query exploration database before SSH detection
   - If running chunks exist, mark workers 'active' even if SSH fails
   - Override worker status: 'offline' → 'active' when chunks running
   - Log: ' Cluster status: ACTIVE (database shows running chunks)'
   - Database is source of truth, SSH only for supplementary metrics

2. app/cluster/page.tsx:
   - Stop button ALREADY EXISTS (conditionally shown)
   - Shows Start when status='idle', Stop when status='active'
   - No code changes needed - fixed by status detection

Result:
- Dashboard now shows 'ACTIVE' with 2 workers (correct)
- Workers show 'active' status (was 'offline')
- Stop button automatically visible when cluster active
- System resilient to SSH timeouts/network issues

Verified:
- Container restarted: Nov 30 21:18 UTC
- API tested: Returns status='active', activeWorkers=2
- Logs confirm: Database-first logic working
- Workers confirmed running: 22+ processes on worker1, workers on worker2
This commit is contained in:
mindesbunister
2025-11-30 22:23:01 +01:00
parent 83b4915d98
commit cc56b72df2
795 changed files with 312766 additions and 281 deletions

28
sweep_v9_optimized.csv Normal file
View File

@@ -0,0 +1,28 @@
flip_threshold_percent,ma_gap_threshold,momentum_min_adx,momentum_long_max_pos,momentum_short_min_pos,cooldown_bars,momentum_spacing,momentum_cooldown,trades,total_pnl,win_rate,avg_pnl,max_drawdown,profit_factor
0.65,0.4,24.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.6,0.4,22.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.4,23.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.4,22.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.35,24.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.35,23.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.55,0.4,22.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.35,22.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.55,0.4,23.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.55,0.4,24.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.6,0.4,24.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.6,0.4,23.0,70.0,30.0,3,4,3,568,496.41424821347374,61.09154929577465,0.8739687468547073,-1270.0386267991928,1.0270047211280526
0.65,0.3,24.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.65,0.3,23.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.65,0.3,22.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.35,23.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.35,24.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.3,24.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.35,22.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.3,23.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.3,24.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.3,22.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.3,23.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.3,22.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.35,24.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.55,0.35,22.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
0.6,0.35,23.0,70.0,30.0,3,4,3,569,405.87730598762016,60.98418277680141,0.7133168822278034,-1360.5755690250467,1.021971337907867
1 flip_threshold_percent ma_gap_threshold momentum_min_adx momentum_long_max_pos momentum_short_min_pos cooldown_bars momentum_spacing momentum_cooldown trades total_pnl win_rate avg_pnl max_drawdown profit_factor
2 0.65 0.4 24.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
3 0.6 0.4 22.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
4 0.65 0.4 23.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
5 0.65 0.4 22.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
6 0.65 0.35 24.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
7 0.65 0.35 23.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
8 0.55 0.4 22.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
9 0.65 0.35 22.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
10 0.55 0.4 23.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
11 0.55 0.4 24.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
12 0.6 0.4 24.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
13 0.6 0.4 23.0 70.0 30.0 3 4 3 568 496.41424821347374 61.09154929577465 0.8739687468547073 -1270.0386267991928 1.0270047211280526
14 0.65 0.3 24.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
15 0.65 0.3 23.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
16 0.65 0.3 22.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
17 0.55 0.35 23.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
18 0.6 0.35 24.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
19 0.55 0.3 24.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
20 0.6 0.35 22.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
21 0.6 0.3 23.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
22 0.6 0.3 24.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
23 0.6 0.3 22.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
24 0.55 0.3 23.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
25 0.55 0.3 22.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
26 0.55 0.35 24.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
27 0.55 0.35 22.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867
28 0.6 0.35 23.0 70.0 30.0 3 4 3 569 405.87730598762016 60.98418277680141 0.7133168822278034 -1360.5755690250467 1.021971337907867