diff --git a/src/services/nostr/index.ts b/src/services/nostr/index.ts index 3dce7b41..3cd90e88 100644 --- a/src/services/nostr/index.ts +++ b/src/services/nostr/index.ts @@ -18,12 +18,12 @@ export default class NostrSubprocess { this.log(ERROR, "nostr subprocess error", error) }) - this.childProcess.on("exit", (code) => { - this.log(ERROR, `nostr subprocess exited with code ${code}`) - if (!code) { + this.childProcess.on("exit", (code, signal) => { + this.log(ERROR, `nostr subprocess exited with code ${code} and signal ${signal}`) + if (code === 0) { return } - throw new Error(`nostr subprocess exited with code ${code}`) + throw new Error(`nostr subprocess exited with code ${code} and signal ${signal}`) }) this.childProcess.on("message", (message: ChildProcessResponse) => { @@ -69,6 +69,6 @@ export default class NostrSubprocess { this.sendToChildProcess({ type: 'send', data, initiator, relays }) } Stop() { - this.childProcess.kill() + this.childProcess.kill(0) } } diff --git a/src/services/storage/db/storageInterface.ts b/src/services/storage/db/storageInterface.ts index 941d9533..85b757f5 100644 --- a/src/services/storage/db/storageInterface.ts +++ b/src/services/storage/db/storageInterface.ts @@ -29,7 +29,7 @@ export class StorageInterface extends EventEmitter { private debug: boolean = false; private utils: Utils private dbType: 'main' | 'metrics' - private log = getLogger({component: 'StorageInterface'}) + private log = getLogger({ component: 'StorageInterface' }) constructor(utils: Utils) { super(); this.initializeSubprocess(); @@ -61,13 +61,13 @@ export class StorageInterface extends EventEmitter { this.isConnected = false; }); - this.process.on('exit', (code: number) => { - this.log(ERROR, `Storage processor exited with code ${code}`); + this.process.on('exit', (code: number, signal: string) => { + this.log(ERROR, `Storage processor exited with code ${code} and signal ${signal}`); this.isConnected = false; - if (!code) { + if (code === 0) { return } - throw new Error(`Storage processor exited with code ${code}`) + throw new Error(`Storage processor exited with code ${code} and signal ${signal}`) }); this.isConnected = true; @@ -179,7 +179,7 @@ export class StorageInterface extends EventEmitter { reject(new Error('Invalid storage response type')); return } - resolve(deserializeResponseData(response.data)); + resolve(deserializeResponseData(response.data)); } this.once(op.opId, responseHandler) this.process.send(this.serializeOperation(op)) @@ -205,7 +205,7 @@ export class StorageInterface extends EventEmitter { public disconnect() { if (this.process) { - this.process.kill(); + this.process.kill(0); this.isConnected = false; this.debug = false; } diff --git a/src/services/storage/tlv/tlvFilesStorageFactory.ts b/src/services/storage/tlv/tlvFilesStorageFactory.ts index 0e396703..3eb2d117 100644 --- a/src/services/storage/tlv/tlvFilesStorageFactory.ts +++ b/src/services/storage/tlv/tlvFilesStorageFactory.ts @@ -53,13 +53,13 @@ export class TlvStorageFactory extends EventEmitter { this.isConnected = false; }); - this.process.on('exit', (code: number) => { - this.log(ERROR, `Tlv Storage processor exited with code ${code}`); + this.process.on('exit', (code: number, signal: string) => { + this.log(ERROR, `Tlv Storage processor exited with code ${code} and signal ${signal}`); this.isConnected = false; - if (!code) { + if (code === 0) { return } - throw new Error(`Tlv Storage processor exited with code ${code}`) + throw new Error(`Tlv Storage processor exited with code ${code} and signal ${signal}`) }); this.isConnected = true; @@ -173,7 +173,7 @@ export class TlvStorageFactory extends EventEmitter { public disconnect() { if (this.process) { - this.process.kill(); + this.process.kill(0); this.isConnected = false; this.debug = false; }