Use dynamic import for autoSyncInit to avoid tsx caching issues

This commit is contained in:
CanbiZ
2025-11-28 14:30:43 +01:00
parent b6c3954f98
commit 6bb9ed5182

View File

@@ -8,10 +8,11 @@ import stripAnsi from 'strip-ansi';
import { spawn as ptySpawn } from 'node-pty';
import { getSSHExecutionService } from './src/server/ssh-execution-service.js';
import { getDatabase } from './src/server/database-prisma.js';
// @ts-ignore - TypeScript has trouble with JS module exports
import { initializeAutoSync, initializeRepositories, setupGracefulShutdown } from './src/server/lib/autoSyncInit.js';
import dotenv from 'dotenv';
// Dynamic import for auto sync init to avoid tsx caching issues
let autoSyncModule = null;
// Load environment variables from .env file
dotenv.config();
// Fallback minimal global error handlers for Node runtime (avoid TS import)
@@ -1240,13 +1241,18 @@ app.prepare().then(() => {
console.log(`> Ready on http://${hostname}:${port}`);
console.log(`> WebSocket server running on ws://${hostname}:${port}/ws/script-execution`);
// Initialize auto sync module and run initialization
if (!autoSyncModule) {
autoSyncModule = await import('./src/server/lib/autoSyncInit.js');
}
// Initialize default repositories
await initializeRepositories();
await autoSyncModule.initializeRepositories();
// Initialize auto-sync service
initializeAutoSync();
autoSyncModule.initializeAutoSync();
// Setup graceful shutdown handlers
setupGracefulShutdown();
autoSyncModule.setupGracefulShutdown();
});
});