mirror of
https://github.com/unraid/api.git
synced 2026-05-20 16:10:15 -05:00
fix: on process exit stop relay connection
This commit is contained in:
@@ -345,6 +345,14 @@ export class CustomSocket {
|
||||
}
|
||||
}
|
||||
|
||||
private onExit(code: number) {
|
||||
// Unbind handlers
|
||||
this.connection?.removeAllListeners();
|
||||
|
||||
// Kill connection with mothership
|
||||
this.connection?.close();
|
||||
}
|
||||
|
||||
private async _connect() {
|
||||
this.connection = new WebSocket(this.uri, ['graphql-ws'], {
|
||||
headers: await this.getHeaders()
|
||||
@@ -355,5 +363,8 @@ export class CustomSocket {
|
||||
this.connection.on('close', this.onDisconnect());
|
||||
this.connection.on('open', this.onConnect());
|
||||
this.connection.on('message', this.onMessage());
|
||||
|
||||
// Unbind handlers and then kill the connection
|
||||
process.once('exit', this.onExit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user