Fix the cleanup running twice
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ node_modules
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
sessions.json
|
sessions.json
|
||||||
client_sessions.json
|
client_sessions.json
|
||||||
|
center_sessions.json
|
||||||
|
24
main.js
24
main.js
@@ -345,11 +345,6 @@ class ClientSessionManager {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.sessions = {};
|
this.sessions = {};
|
||||||
process.on('exit', this.cleanup.bind(this));
|
|
||||||
process.on('SIGINT', this.cleanup.bind(this));
|
|
||||||
process.on('SIGUSR1', this.cleanup.bind(this));
|
|
||||||
process.on('SIGUSR2', this.cleanup.bind(this));
|
|
||||||
process.on('uncaughtException', this.cleanup.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createSession(url, username, password) {
|
createSession(url, username, password) {
|
||||||
@@ -392,7 +387,6 @@ class ClientSessionManager {
|
|||||||
cleanup() {
|
cleanup() {
|
||||||
this.logger.log1(`Saving sessions to ${CLIENT_SESSIONS_FILE}...`);
|
this.logger.log1(`Saving sessions to ${CLIENT_SESSIONS_FILE}...`);
|
||||||
fs.writeFileSync(CLIENT_SESSIONS_FILE, JSON.stringify(this.serialize(), null, 4));
|
fs.writeFileSync(CLIENT_SESSIONS_FILE, JSON.stringify(this.serialize(), null, 4));
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startup() {
|
startup() {
|
||||||
@@ -620,11 +614,6 @@ class CenterSessionManager {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.servers = {};
|
this.servers = {};
|
||||||
process.on('exit', this.cleanup.bind(this));
|
|
||||||
process.on('SIGINT', this.cleanup.bind(this));
|
|
||||||
process.on('SIGUSR1', this.cleanup.bind(this));
|
|
||||||
process.on('SIGUSR2', this.cleanup.bind(this));
|
|
||||||
process.on('uncaughtException', this.cleanup.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createSession(port, username, password) {
|
createSession(port, username, password) {
|
||||||
@@ -666,7 +655,6 @@ class CenterSessionManager {
|
|||||||
cleanup() {
|
cleanup() {
|
||||||
this.logger.log1(`Saving sessions to ${CENTER_SESSIONS_FILE}...`);
|
this.logger.log1(`Saving sessions to ${CENTER_SESSIONS_FILE}...`);
|
||||||
fs.writeFileSync(CENTER_SESSIONS_FILE, JSON.stringify(this.serialize(), null, 4));
|
fs.writeFileSync(CENTER_SESSIONS_FILE, JSON.stringify(this.serialize(), null, 4));
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startup() {
|
startup() {
|
||||||
@@ -1090,3 +1078,15 @@ session.connect().then(() => session.bind());
|
|||||||
|
|
||||||
new WSServer();
|
new WSServer();
|
||||||
new HTTPServer();
|
new HTTPServer();
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
clientSessionManager.cleanup();
|
||||||
|
centerSessionManager.cleanup();
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('exit', cleanup);
|
||||||
|
process.on('SIGINT', cleanup);
|
||||||
|
process.on('SIGUSR1', cleanup);
|
||||||
|
process.on('SIGUSR2', cleanup);
|
||||||
|
process.on('uncaughtException', cleanup);
|
Reference in New Issue
Block a user