Spaces:
Sleeping
Sleeping
File size: 1,422 Bytes
61b1da1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import { fork } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, '..');
const API_PORT = process.env.API_PORT || '3894';
const MCP_PORT = process.env.PORT || process.env.MCP_PORT || '7860';
console.log('====================================================');
console.log('🧠 Ever-Brain Unified Gateway Server');
console.log(`📡 Public MCP Port: ${MCP_PORT}`);
console.log(`⚙️ Internal API Port: ${API_PORT}`);
console.log('====================================================');
// 1. Start Internal API Engine
const apiProcess = fork(path.join(rootDir, 'packages/api/dist/index.js'), [], {
env: {
...process.env,
PORT: API_PORT,
API_PORT: API_PORT,
},
stdio: 'inherit',
});
// Wait briefly for API engine to initialize
await new Promise((resolve) => setTimeout(resolve, 800));
// 2. Start Live MCP Server
const mcpProcess = fork(path.join(rootDir, 'packages/mcp/dist/index.js'), [], {
env: {
...process.env,
PORT: MCP_PORT,
MCP_PORT: MCP_PORT,
EVB_API_URL: `http://localhost:${API_PORT}`,
API_URL: `http://localhost:${API_PORT}`,
},
stdio: 'inherit',
});
const cleanup = () => {
apiProcess.kill();
mcpProcess.kill();
process.exit(0);
};
process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup);
|