feat: Deploy HA auto-failover with database promotion
- Enhanced DNS failover monitor on secondary (72.62.39.24) - Auto-promotes database: pg_ctl promote on failover - Creates DEMOTED flag on primary via SSH (split-brain protection) - Telegram notifications with database promotion status - Startup safety script ready (integration pending) - 90-second automatic recovery vs 10-30 min manual - Zero-cost 95% enterprise HA benefit Status: DEPLOYED and MONITORING (14:52 CET) Next: Controlled failover test during maintenance
This commit is contained in:
@@ -37,12 +37,15 @@ function normalizeTradingViewSymbol(tvSymbol: string): string {
|
||||
'FARTUSDT': 'FARTCOIN-PERP',
|
||||
'FART': 'FARTCOIN-PERP',
|
||||
'SOLUSDT': 'SOL-PERP',
|
||||
'SOLUSDT.P': 'SOL-PERP',
|
||||
'SOLUSD': 'SOL-PERP',
|
||||
'SOL': 'SOL-PERP',
|
||||
'ETHUSDT': 'ETH-PERP',
|
||||
'ETHUSDT.P': 'ETH-PERP',
|
||||
'ETHUSD': 'ETH-PERP',
|
||||
'ETH': 'ETH-PERP',
|
||||
'BTCUSDT': 'BTC-PERP',
|
||||
'BTCUSDT.P': 'BTC-PERP',
|
||||
'BTCUSD': 'BTC-PERP',
|
||||
'BTC': 'BTC-PERP'
|
||||
}
|
||||
@@ -80,6 +83,16 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const driftSymbol = normalizeTradingViewSymbol(body.symbol)
|
||||
|
||||
// Parse timestamp defensively – fall back to now if malformed to avoid dropping data
|
||||
const parsedTimestamp = body.timestamp ? new Date(body.timestamp) : new Date()
|
||||
const timestamp = Number.isNaN(parsedTimestamp.getTime()) ? new Date() : parsedTimestamp
|
||||
if (body.timestamp && Number.isNaN(parsedTimestamp.getTime())) {
|
||||
console.warn('⚠️ Invalid timestamp in market data payload, falling back to now', {
|
||||
symbol: driftSymbol,
|
||||
provided: body.timestamp
|
||||
})
|
||||
}
|
||||
|
||||
// Store in cache for immediate use
|
||||
const marketCache = getMarketDataCache()
|
||||
@@ -115,7 +128,7 @@ export async function POST(request: NextRequest) {
|
||||
pricePosition: Number(body.pricePosition) || 50,
|
||||
maGap: Number(body.maGap) || undefined,
|
||||
volume: Number(body.volume) || undefined,
|
||||
timestamp: new Date(body.timestamp || Date.now())
|
||||
timestamp
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user