handle exit signal when code is null
This commit is contained in:
parent
44c55f3baa
commit
3b827626a6
3 changed files with 17 additions and 17 deletions
|
|
@ -18,12 +18,12 @@ export default class NostrSubprocess {
|
||||||
this.log(ERROR, "nostr subprocess error", error)
|
this.log(ERROR, "nostr subprocess error", error)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.childProcess.on("exit", (code) => {
|
this.childProcess.on("exit", (code, signal) => {
|
||||||
this.log(ERROR, `nostr subprocess exited with code ${code}`)
|
this.log(ERROR, `nostr subprocess exited with code ${code} and signal ${signal}`)
|
||||||
if (!code) {
|
if (code === 0) {
|
||||||
return
|
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) => {
|
this.childProcess.on("message", (message: ChildProcessResponse) => {
|
||||||
|
|
@ -69,6 +69,6 @@ export default class NostrSubprocess {
|
||||||
this.sendToChildProcess({ type: 'send', data, initiator, relays })
|
this.sendToChildProcess({ type: 'send', data, initiator, relays })
|
||||||
}
|
}
|
||||||
Stop() {
|
Stop() {
|
||||||
this.childProcess.kill()
|
this.childProcess.kill(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export class StorageInterface extends EventEmitter {
|
||||||
private debug: boolean = false;
|
private debug: boolean = false;
|
||||||
private utils: Utils
|
private utils: Utils
|
||||||
private dbType: 'main' | 'metrics'
|
private dbType: 'main' | 'metrics'
|
||||||
private log = getLogger({component: 'StorageInterface'})
|
private log = getLogger({ component: 'StorageInterface' })
|
||||||
constructor(utils: Utils) {
|
constructor(utils: Utils) {
|
||||||
super();
|
super();
|
||||||
this.initializeSubprocess();
|
this.initializeSubprocess();
|
||||||
|
|
@ -61,13 +61,13 @@ export class StorageInterface extends EventEmitter {
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.process.on('exit', (code: number) => {
|
this.process.on('exit', (code: number, signal: string) => {
|
||||||
this.log(ERROR, `Storage processor exited with code ${code}`);
|
this.log(ERROR, `Storage processor exited with code ${code} and signal ${signal}`);
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
if (!code) {
|
if (code === 0) {
|
||||||
return
|
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;
|
this.isConnected = true;
|
||||||
|
|
@ -205,7 +205,7 @@ export class StorageInterface extends EventEmitter {
|
||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
if (this.process) {
|
if (this.process) {
|
||||||
this.process.kill();
|
this.process.kill(0);
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
this.debug = false;
|
this.debug = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,13 @@ export class TlvStorageFactory extends EventEmitter {
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.process.on('exit', (code: number) => {
|
this.process.on('exit', (code: number, signal: string) => {
|
||||||
this.log(ERROR, `Tlv Storage processor exited with code ${code}`);
|
this.log(ERROR, `Tlv Storage processor exited with code ${code} and signal ${signal}`);
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
if (!code) {
|
if (code === 0) {
|
||||||
return
|
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;
|
this.isConnected = true;
|
||||||
|
|
@ -173,7 +173,7 @@ export class TlvStorageFactory extends EventEmitter {
|
||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
if (this.process) {
|
if (this.process) {
|
||||||
this.process.kill();
|
this.process.kill(0);
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
this.debug = false;
|
this.debug = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue