Archived
1
0

Get boostrap stuff forking

They don't run yet but seem to be forking correctly now.
This commit is contained in:
Asher
2019-01-22 18:28:54 -06:00
committed by Kyle Carberry
parent b1cd5c142f
commit 8a789ac957
6 changed files with 32 additions and 11 deletions

View File

@ -44,14 +44,33 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
const server = new Server(connection, options ? {
...options,
forkProvider: (message: NewSessionMessage): ChildProcess => {
let proc: ChildProcess;
const command = message.getCommand();
const childLogger = logger.named(command.split("/").pop()!);
childLogger.debug("Forking...", field("module", command));
let proc: ChildProcess;
if (message.getIsBootstrapFork()) {
proc = forkModule(message.getCommand());
proc = forkModule(command);
} else {
throw new Error("No support for non bootstrap-forking yet");
}
proc.stdout.on("data", (message) => {
childLogger.debug("stdout", field("message", message.toString().trim()));
});
proc.stderr.on("data", (message) => {
childLogger.debug("stderr", field("message", message.toString().trim()));
});
proc.stdin.on("data", (message) => {
childLogger.debug("stdin", field("message", message.toString().trim()));
});
proc.on("exit", (exitCode) => {
childLogger.debug(`Exited with ${exitCode}`);
});
return proc;
},
} : undefined);

View File

@ -29,7 +29,7 @@ export class SharedProcess {
private activeProcess: ChildProcess | undefined;
private ipcHandler: StdioIpcHandler | undefined;
private readonly onStateEmitter: Emitter<SharedProcessEvent>;
private readonly logger = logger.named("SHDR PROC");
private readonly logger = logger.named("SHRD PROC");
public constructor(
private readonly userDataDir: string,