mirror of https://github.com/waku-org/js-waku.git
Add logs to track nim-waku process
This commit is contained in:
parent
30b0d5785a
commit
e99d1c012c
|
@ -33,6 +33,7 @@ export interface Args {
|
||||||
|
|
||||||
export class NimWaku {
|
export class NimWaku {
|
||||||
private process?: ChildProcess;
|
private process?: ChildProcess;
|
||||||
|
private pid?: number;
|
||||||
private portsShift: number;
|
private portsShift: number;
|
||||||
private peerId?: PeerId;
|
private peerId?: PeerId;
|
||||||
private logPath: string;
|
private logPath: string;
|
||||||
|
@ -70,21 +71,38 @@ export class NimWaku {
|
||||||
logFile, // stderr
|
logFile, // stderr
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
this.pid = this.process.pid;
|
||||||
|
console.log(
|
||||||
|
`nim-waku ${
|
||||||
|
this.process.pid
|
||||||
|
} started at ${new Date().toLocaleTimeString()}`
|
||||||
|
);
|
||||||
|
|
||||||
this.process.on('exit', (signal) => {
|
this.process.on('exit', (signal) => {
|
||||||
if (signal != 0) {
|
console.log(
|
||||||
console.log(`nim-waku process exited with ${signal}`);
|
`nim-waku ${
|
||||||
}
|
this.process ? this.process.pid : this.pid
|
||||||
|
} process exited with ${signal} at ${new Date().toLocaleTimeString()}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.process.on('error', (err) => {
|
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');
|
await this.waitForLog('RPC Server started');
|
||||||
}
|
}
|
||||||
|
|
||||||
public stop() {
|
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 ? this.process.kill('SIGINT') : null;
|
||||||
this.process = undefined;
|
this.process = undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue