Skip to content

Commit c87a87c

Browse files
rcourtmanclaude
andcommitted
fix: allow server to start without configuration
- Change configuration loader to warn instead of throwing error when config is missing - Allow server to start in setup mode with empty endpoints - Skip API client initialization when no endpoints are configured - This enables the web-based setup flow to work properly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1e5451e commit c87a87c

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

server/configLoader.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,16 @@ function loadConfiguration() {
123123

124124
// Throw error only if required vars are MISSING
125125
if (missingVars.length > 0) {
126-
let errorMessages = ['--- Configuration Error (Primary Endpoint) ---'];
127-
errorMessages.push(`Missing required environment variables: ${missingVars.join(', ')}.`);
128-
errorMessages.push('Please ensure valid Proxmox connection details are provided.');
129-
errorMessages.push('Refer to server/.env.example for the required variable names and format.');
130-
throw new ConfigurationError(errorMessages.join('\n'));
126+
console.warn('--- Configuration Warning ---');
127+
console.warn(`Missing required environment variables: ${missingVars.join(', ')}.`);
128+
console.warn('Pulse will start in setup mode. Please configure via the web interface.');
129+
130+
// Return minimal configuration to allow server to start
131+
return {
132+
endpoints: [],
133+
pbsConfigs: [],
134+
isConfigPlaceholder: true
135+
};
131136
}
132137

133138
// Set the flag if placeholders were detected (but don't throw error)

server/index.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -957,22 +957,31 @@ function setupEnvFileWatcher() {
957957

958958
// --- Start the server ---
959959
async function startServer() {
960-
try {
961-
// Use the correct initializer function name
962-
const initializedClients = await initializeApiClients(endpoints, pbsConfigs);
963-
apiClients = initializedClients.apiClients;
964-
pbsApiClients = initializedClients.pbsApiClients;
960+
// Only initialize API clients if we have endpoints configured
961+
if (endpoints.length > 0 || pbsConfigs.length > 0) {
962+
try {
963+
// Use the correct initializer function name
964+
const initializedClients = await initializeApiClients(endpoints, pbsConfigs);
965+
apiClients = initializedClients.apiClients;
966+
pbsApiClients = initializedClients.pbsApiClients;
967+
968+
// Store globally for config reload
969+
global.pulseApiClients = { apiClients, pbsApiClients };
970+
971+
console.log("INFO: All API clients initialized.");
972+
} catch (initError) {
973+
console.error("FATAL: Failed to initialize API clients:", initError);
974+
process.exit(1); // Exit if clients can't be initialized
975+
}
965976

966-
// Store globally for config reload
977+
await runDiscoveryCycle();
978+
} else {
979+
console.log("INFO: No endpoints configured. Starting in setup mode.");
980+
// Initialize empty clients for consistency
981+
apiClients = new Map();
982+
pbsApiClients = new Map();
967983
global.pulseApiClients = { apiClients, pbsApiClients };
968-
969-
console.log("INFO: All API clients initialized.");
970-
} catch (initError) {
971-
console.error("FATAL: Failed to initialize API clients:", initError);
972-
process.exit(1); // Exit if clients can't be initialized
973-
}
974-
975-
await runDiscoveryCycle();
984+
}
976985

977986
server.listen(PORT, () => {
978987
console.log(`Server listening on port ${PORT}`);

0 commit comments

Comments
 (0)