api: always create separate server for itunnels

This commit is contained in:
jj 2024-12-16 10:19:15 +00:00
parent e7c2872e40
commit f06aa65801
No known key found for this signature in database

View file

@ -316,8 +316,6 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
return stream(res, { type: 'internal', ...streamInfo }); return stream(res, { type: 'internal', ...streamInfo });
}; };
app.get('/itunnel', itunnelHandler);
app.get('/', (_, res) => { app.get('/', (_, res) => {
res.type('json'); res.type('json');
res.status(200).send(serverInfo); res.status(200).send(serverInfo);
@ -378,17 +376,15 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
} }
}); });
if (isCluster) { const istreamer = express();
const istreamer = express(); istreamer.get('/itunnel', itunnelHandler);
istreamer.get('/itunnel', itunnelHandler); const server = istreamer.listen({
const server = istreamer.listen({ port: 0,
port: 0, host: '127.0.0.1',
host: '127.0.0.1', exclusive: true
exclusive: true }, () => {
}, () => { const { port } = server.address();
const { port } = server.address(); console.log(`${Green('[✓]')} cobalt sub-instance running on 127.0.0.1:${port}`);
console.log(`${Green('[✓]')} cobalt sub-instance running on 127.0.0.1:${port}`); setTunnelPort(port);
setTunnelPort(port); });
});
}
} }