Skip to content

Commit 4976295

Browse files
rcourtmanclaude
andcommitted
debug: add comprehensive logging for configuration reload process
- Add detailed logging for endpoint loading and API client initialization - Clear environment variables more aggressively during reload - Add manual verification of additional endpoints in environment - Help diagnose why additional nodes might require server restart 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 19c3d0b commit 4976295

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

server/configApi.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,26 @@ class ConfigApi {
427427
// Clear the require cache for dotenv
428428
delete require.cache[require.resolve('dotenv')];
429429

430+
// Clear all environment variables that might be cached
431+
Object.keys(process.env).forEach(key => {
432+
if (key.startsWith('PROXMOX_') || key.startsWith('PBS_') || key.startsWith('PULSE_') || key.startsWith('ALERT_')) {
433+
delete process.env[key];
434+
}
435+
});
436+
430437
// Reload environment variables
431438
require('dotenv').config();
432439

440+
// Log environment variables for debugging
441+
const envVars = Object.keys(process.env).filter(key =>
442+
key.startsWith('PROXMOX_') || key.startsWith('PBS_')
443+
).sort();
444+
console.log('[ConfigApi.reloadConfiguration] Environment variables after reload:', envVars);
445+
433446
// Reload configuration
434447
const { endpoints, pbsConfigs, isConfigPlaceholder } = loadConfiguration();
448+
console.log(`[ConfigApi.reloadConfiguration] Loaded ${endpoints.length} Proxmox endpoints:`, endpoints.map(e => ({ id: e.id, name: e.name, host: e.host })));
449+
console.log(`[ConfigApi.reloadConfiguration] Loaded ${pbsConfigs.length} PBS configs:`, pbsConfigs.map(p => ({ id: p.id, name: p.name, host: p.host })));
435450

436451
// Get state manager instance
437452
const stateManager = require('./state');
@@ -441,7 +456,10 @@ class ConfigApi {
441456
stateManager.setEndpointConfigurations(endpoints, pbsConfigs);
442457

443458
// Reinitialize API clients
459+
console.log('[ConfigApi.reloadConfiguration] Reinitializing API clients...');
444460
const { apiClients, pbsApiClients } = await initializeApiClients(endpoints, pbsConfigs);
461+
console.log(`[ConfigApi.reloadConfiguration] Initialized ${Object.keys(apiClients).length} API clients:`, Object.keys(apiClients));
462+
console.log(`[ConfigApi.reloadConfiguration] Initialized ${Object.keys(pbsApiClients).length} PBS clients:`, Object.keys(pbsApiClients));
445463

446464
// Update global references
447465
if (global.pulseApiClients) {
@@ -459,6 +477,16 @@ class ConfigApi {
459477
global.lastReloadTime = Date.now();
460478
}
461479

480+
// Manually verify additional endpoints are loaded
481+
let additionalEndpointsFound = 0;
482+
let i = 2;
483+
while (process.env[`PROXMOX_HOST_${i}`]) {
484+
console.log(`[ConfigApi.reloadConfiguration] Found additional endpoint ${i}: PROXMOX_HOST_${i}=${process.env[`PROXMOX_HOST_${i}`]}`);
485+
additionalEndpointsFound++;
486+
i++;
487+
}
488+
console.log(`[ConfigApi.reloadConfiguration] Total additional endpoints found in environment: ${additionalEndpointsFound}`);
489+
462490
// Trigger a discovery cycle if we have endpoints configured
463491
if (endpoints.length > 0) {
464492
console.log('Triggering discovery cycle after configuration reload...');

0 commit comments

Comments
 (0)