ssh tunnel - reuse SSH connection + local port for multiple DB connections

This commit is contained in:
Jan Prochazka
2021-02-13 07:47:55 +01:00
parent 728ca72cc1
commit 114dc0b543
15 changed files with 172 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
const { fork } = require('child_process');
const uuidv1 = require('uuid/v1');
const { handleProcessCommunication } = require('./processComm');
class DatastoreProxy {
constructor(file) {
@@ -30,8 +31,11 @@ class DatastoreProxy {
if (!this.subprocess) {
this.subprocess = fork(process.argv[1], ['jslDatastoreProcess', ...process.argv.slice(3)]);
// @ts-ignore
this.subprocess.on('message', ({ msgtype, ...message }) => {
this.subprocess.on('message', message => {
// @ts-ignore
const { msgtype } = message;
if (handleProcessCommunication(message, this.subprocess)) return;
// if (this.disconnected) return;
this[`handle_${msgtype}`](message);
});