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);
|
this.app.use('/api/kernel', kernelRoutes);
|
||||||
|
|
||||||
// Serve dashboard HTML
|
// Serve dashboard HTML
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
// Suporte a ESM e CommonJS (build do Docker)
|
||||||
const __dirname = dirname(__filename);
|
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');
|
const publicPath = join(__dirname, 'public');
|
||||||
|
|
||||||
this.app.get('/', (req: Request, res: Response) => {
|
this.app.get('/', (req: Request, res: Response) => {
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,15 @@ import { LogAggregator } from './core/LogAggregator';
|
||||||
import { DashboardServer } from './dashboard/DashboardServer';
|
import { DashboardServer } from './dashboard/DashboardServer';
|
||||||
import { ServiceConfig, ServiceState } from './types';
|
import { ServiceConfig, ServiceState } from './types';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
// Suporte a ESM e CommonJS (build do Docker)
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = (() => {
|
||||||
|
try {
|
||||||
|
return dirname(fileURLToPath(import.meta.url));
|
||||||
|
} catch {
|
||||||
|
// Fallback para CommonJS build
|
||||||
|
return join(process.cwd(), 'server', 'kernel');
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
export interface KernelOptions {
|
export interface KernelOptions {
|
||||||
configPath?: string;
|
configPath?: string;
|
||||||
|
|
@ -200,7 +207,9 @@ export { createKernelRoutes } from './api/routes';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
|
||||||
// Entry point para execução direta
|
// Entry point para execução direta
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
// Protegido para funcionar no build CommonJS do Docker
|
||||||
|
try {
|
||||||
|
if (import.meta.url && import.meta.url === `file://${process.argv[1]}`) {
|
||||||
const kernel = new ArcadiaKernel({
|
const kernel = new ArcadiaKernel({
|
||||||
dashboard: { enabled: true, port: 5001 },
|
dashboard: { enabled: true, port: 5001 },
|
||||||
autoStart: true,
|
autoStart: true,
|
||||||
|
|
@ -211,3 +220,6 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
// No build CommonJS, o Kernel é iniciado pelo server/index.ts
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue