Use dynamic import for autoSyncInit to avoid tsx caching issues
This commit is contained in:
16
server.js
16
server.js
@@ -8,10 +8,11 @@ import stripAnsi from 'strip-ansi';
|
|||||||
import { spawn as ptySpawn } from 'node-pty';
|
import { spawn as ptySpawn } from 'node-pty';
|
||||||
import { getSSHExecutionService } from './src/server/ssh-execution-service.js';
|
import { getSSHExecutionService } from './src/server/ssh-execution-service.js';
|
||||||
import { getDatabase } from './src/server/database-prisma.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';
|
import dotenv from 'dotenv';
|
||||||
|
|
||||||
|
// Dynamic import for auto sync init to avoid tsx caching issues
|
||||||
|
let autoSyncModule = null;
|
||||||
|
|
||||||
// Load environment variables from .env file
|
// Load environment variables from .env file
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
// Fallback minimal global error handlers for Node runtime (avoid TS import)
|
// 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(`> Ready on http://${hostname}:${port}`);
|
||||||
console.log(`> WebSocket server running on ws://${hostname}:${port}/ws/script-execution`);
|
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
|
// Initialize default repositories
|
||||||
await initializeRepositories();
|
await autoSyncModule.initializeRepositories();
|
||||||
|
|
||||||
// Initialize auto-sync service
|
// Initialize auto-sync service
|
||||||
initializeAutoSync();
|
autoSyncModule.initializeAutoSync();
|
||||||
|
|
||||||
// Setup graceful shutdown handlers
|
// Setup graceful shutdown handlers
|
||||||
setupGracefulShutdown();
|
autoSyncModule.setupGracefulShutdown();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user