Refactor daemon connection logic and enhance logging

- Improved handling of daemon URL configuration based on environment variables
- Added detailed logging for daemon connection status and environment settings
- Streamlined fallback logic for local development and production environments
This commit is contained in:
Torsten Schulz (local)
2025-11-18 08:37:02 +01:00
parent d8b1efc3ca
commit 016a37c116

View File

@@ -256,15 +256,22 @@ const store = createStore({
// Daemon URL für lokale Entwicklung und Produktion // Daemon URL für lokale Entwicklung und Produktion
let daemonUrl = import.meta.env.VITE_DAEMON_SOCKET; let daemonUrl = import.meta.env.VITE_DAEMON_SOCKET;
// Für lokale Entwicklung: direkte Daemon-Verbindung console.log('[Daemon] Umgebungsvariable VITE_DAEMON_SOCKET:', daemonUrl);
if (!daemonUrl && (import.meta.env.DEV || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) { console.log('[Daemon] DEV-Modus:', import.meta.env.DEV);
daemonUrl = 'ws://localhost:4551'; console.log('[Daemon] Hostname:', window.location.hostname);
}
// Fallback für Produktion // Nur wenn Umgebungsvariable NICHT gesetzt ist, Fallback-Logik verwenden
if (!daemonUrl) { if (!daemonUrl) {
// Für lokale Entwicklung: direkte Daemon-Verbindung
if (import.meta.env.DEV || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
daemonUrl = 'ws://localhost:4551';
} else {
// Fallback für Produktion
daemonUrl = 'wss://www.your-part.de:4551'; daemonUrl = 'wss://www.your-part.de:4551';
} }
}
console.log('[Daemon] Finale Daemon-URL:', daemonUrl);
const connectDaemonSocket = () => { const connectDaemonSocket = () => {
// Cleanup existing socket and timer // Cleanup existing socket and timer