Centralize fork logging

This commit is contained in:
Asher
2019-01-22 19:05:56 -06:00
committed by Kyle Carberry
parent 8a789ac957
commit 704a0defc9
3 changed files with 47 additions and 33 deletions

View File

@@ -44,33 +44,13 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
const server = new Server(connection, options ? {
...options,
forkProvider: (message: NewSessionMessage): 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(command);
proc = forkModule(message.getCommand());
} 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);