#!/bin/bash set -euo pipefail ENV=/opt/ai-fresh-delivery/server/.env cd /opt/ai-fresh-delivery/server echo "=== .env thresholds ===" grep -E '^ARK_BALANCE_' "$ENV" || true echo "" echo "=== service vs .env mtime ===" echo "service_started: $(systemctl show ai-fresh-api -p ActiveEnterTimestamp --value)" echo "env_modified: $(stat -c '%y' "$ENV" | cut -d. -f1)" echo "" echo "=== effective thresholds (env + db) ===" node <<'NODE' require('./dist/env.js').loadEnv(); const { pool } = require('./dist/db.js').pool ? { pool: require('./dist/db.js').pool } : require('./dist/db.js'); const { getArkBalanceStatus } = require('./dist/services/arkBalanceService.js'); (async () => { const envWarn = Number(process.env.ARK_BALANCE_WARN_YUAN) || 100; const envCritical = Number(process.env.ARK_BALANCE_CRITICAL_YUAN) || 20; console.log('env_warn_yuan:', envWarn); console.log('env_critical_yuan:', envCritical); const db = await pool.query( `SELECT config_value FROM system_configs WHERE config_key = 'ark_balance_alert' AND branch_code IS NULL LIMIT 1` ); console.log('db_config:', JSON.stringify(db.rows[0]?.config_value || null)); const status = await getArkBalanceStatus({ forceRefresh: true }); console.log('effective_warn_yuan:', status.thresholds.warnYuan); console.log('effective_critical_yuan:', status.thresholds.criticalYuan); console.log('notify_interval_hours:', status.thresholds.notifyIntervalHours); console.log('billing_configured:', status.billingConfigured); console.log('query_ok:', status.queryOk); console.log('available_balance_yuan:', status.availableBalanceYuan); console.log('alert_level:', status.alertLevel); console.log('alert_message:', status.alertMessage || '(none)'); if (status.error) console.log('error:', status.error); await pool.end(); })().catch((e) => { console.error('FAIL', e.message); pool.end().finally(() => process.exit(1)); }); NODE