fix(build): compatibilidade CommonJS para Kernel
- Adiciona fallback para import.meta.url em builds do Docker - Protege entry point do Kernel para não crashar em CommonJS - DashboardServer.ts agora funciona em ESM e CommonJS - index.ts com try-catch em torno de import.meta.url Isso corrige o erro: ERR_INVALID_ARG_TYPE no build do Coolify Refs: Deploy produção com Kernel
This commit is contained in:
parent
75953a8542
commit
5ba2bd963d
|
|
@ -105,8 +105,15 @@ export class DashboardServer {
|
|||
this.app.use('/api/kernel', kernelRoutes);
|
||||
|
||||
// Serve dashboard HTML
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
// Suporte a ESM e CommonJS (build do Docker)
|
||||
const __dirname = (() => {
|
||||
try {
|
||||
return dirname(fileURLToPath(import.meta.url));
|
||||
} catch {
|
||||
// Fallback para CommonJS build
|
||||
return join(process.cwd(), 'server', 'kernel', 'dashboard');
|
||||
}
|
||||
})();
|
||||
const publicPath = join(__dirname, 'public');
|
||||
|
||||
this.app.get('/', (req: Request, res: Response) => {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,15 @@ import { LogAggregator } from './core/LogAggregator';
|
|||
import { DashboardServer } from './dashboard/DashboardServer';
|
||||
import { ServiceConfig, ServiceState } from './types';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
// Suporte a ESM e CommonJS (build do Docker)
|
||||
const __dirname = (() => {
|
||||
try {
|
||||
return dirname(fileURLToPath(import.meta.url));
|
||||
} catch {
|
||||
// Fallback para CommonJS build
|
||||
return join(process.cwd(), 'server', 'kernel');
|
||||
}
|
||||
})();
|
||||
|
||||
export interface KernelOptions {
|
||||
configPath?: string;
|
||||
|
|
@ -200,14 +207,19 @@ export { createKernelRoutes } from './api/routes';
|
|||
export * from './types';
|
||||
|
||||
// Entry point para execução direta
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const kernel = new ArcadiaKernel({
|
||||
dashboard: { enabled: true, port: 5001 },
|
||||
autoStart: true,
|
||||
});
|
||||
// Protegido para funcionar no build CommonJS do Docker
|
||||
try {
|
||||
if (import.meta.url && import.meta.url === `file://${process.argv[1]}`) {
|
||||
const kernel = new ArcadiaKernel({
|
||||
dashboard: { enabled: true, port: 5001 },
|
||||
autoStart: true,
|
||||
});
|
||||
|
||||
kernel.start().catch((error) => {
|
||||
console.error('[Kernel] Falha ao iniciar:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
kernel.start().catch((error) => {
|
||||
console.error('[Kernel] Falha ao iniciar:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// No build CommonJS, o Kernel é iniciado pelo server/index.ts
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue