Add logs to track nim-waku process

This commit is contained in:
Franck Royer 2021-03-26 13:07:47 +11:00
parent 30b0d5785a
commit e99d1c012c
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 22 additions and 4 deletions

View File

@ -33,6 +33,7 @@ export interface Args {
export class NimWaku {
private process?: ChildProcess;
private pid?: number;
private portsShift: number;
private peerId?: PeerId;
private logPath: string;
@ -70,21 +71,38 @@ export class NimWaku {
logFile, // stderr
],
});
this.pid = this.process.pid;
console.log(
`nim-waku ${
this.process.pid
} started at ${new Date().toLocaleTimeString()}`
);
this.process.on('exit', (signal) => {
if (signal != 0) {
console.log(`nim-waku process exited with ${signal}`);
}
console.log(
`nim-waku ${
this.process ? this.process.pid : this.pid
} process exited with ${signal} at ${new Date().toLocaleTimeString()}`
);
});
this.process.on('error', (err) => {
console.log(`nim-waku process encountered an error: ${err}`);
console.log(
`nim-waku ${
this.process ? this.process.pid : this.pid
} process encountered an error: ${err} at ${new Date().toLocaleTimeString()}`
);
});
await this.waitForLog('RPC Server started');
}
public stop() {
console.log(
`nim-waku ${
this.process ? this.process.pid : this.pid
} getting SIGINT at ${new Date().toLocaleTimeString()}`
);
this.process ? this.process.kill('SIGINT') : null;
this.process = undefined;
}