events work in electron IPC

This commit is contained in:
Jan Prochazka
2021-12-25 10:52:48 +01:00
parent 6dcbb5e308
commit 185cfab5d8
13 changed files with 68 additions and 40 deletions

View File

@@ -136,7 +136,11 @@ module.exports = {
raw: true,
},
test(req, res) {
const subprocess = fork(process.argv[1], ['--start-process', 'connectProcess', ...process.argv.slice(3)]);
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--start-process',
'connectProcess',
...process.argv.slice(3),
]);
subprocess.on('message', resp => {
if (handleProcessCommunication(resp, subprocess)) return;
// @ts-ignore

View File

@@ -74,7 +74,7 @@ module.exports = {
const existing = this.opened.find(x => x.conid == conid && x.database == database);
if (existing) return existing;
const connection = await connections.get({ conid });
const subprocess = fork(process.argv[1], [
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--start-process',
'databaseConnectionProcess',
...process.argv.slice(3),

View File

@@ -103,7 +103,7 @@ module.exports = {
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
env: {
...process.env,
DBGATE_API: global['dbgateApiModulePath'] || process.argv[1],
DBGATE_API: global['API_PACKAGE'] || global['dbgateApiModulePath'] || process.argv[1],
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, getPluginBackendPath(name)])),
},
});

View File

@@ -37,7 +37,7 @@ module.exports = {
const existing = this.opened.find(x => x.conid == conid);
if (existing) return existing;
const connection = await connections.get({ conid });
const subprocess = fork(process.argv[1], [
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--start-process',
'serverConnectionProcess',
...process.argv.slice(3),

View File

@@ -65,7 +65,11 @@ module.exports = {
async create({ conid, database }) {
const sesid = uuidv1();
const connection = await connections.get({ conid });
const subprocess = fork(process.argv[1], ['--start-process', 'sessionProcess', ...process.argv.slice(3)]);
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--start-process',
'sessionProcess',
...process.argv.slice(3),
]);
const newOpened = {
conid,
database,