Hook up shared process sorta
This commit is contained in:
@ -117,9 +117,11 @@ export class Entry extends Command {
|
||||
app.wss.on("connection", (ws, req) => {
|
||||
const id = clientId++;
|
||||
|
||||
if (sharedProcess.state === SharedProcessState.Ready) {
|
||||
sendSharedProcessReady(ws);
|
||||
}
|
||||
ws.on("open", () => {
|
||||
if (sharedProcess.state === SharedProcessState.Ready) {
|
||||
sendSharedProcessReady(ws);
|
||||
}
|
||||
});
|
||||
|
||||
logger.info(`WebSocket opened \u001B[0m${req.url}`, field("client", id), field("ip", req.socket.remoteAddress));
|
||||
|
||||
|
@ -25,12 +25,6 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
|
||||
};
|
||||
|
||||
wss.on("connection", (ws: WebSocket, req) => {
|
||||
const spm = (<any>req).sharedProcessInit as SharedProcessInitMessage;
|
||||
if (!spm) {
|
||||
ws.close();
|
||||
return;
|
||||
}
|
||||
|
||||
const connection: ReadWriteConnection = {
|
||||
onMessage: (cb): void => {
|
||||
ws.addEventListener("message", (event) => cb(event.data));
|
||||
@ -44,7 +38,7 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
|
||||
...options,
|
||||
forkProvider: (message: NewSessionMessage): ChildProcess => {
|
||||
let proc: ChildProcess;
|
||||
|
||||
|
||||
if (message.getIsBootstrapFork()) {
|
||||
proc = forkModule(message.getCommand());
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user