mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 19:36:00 +00:00
pass ntive modules fix
This commit is contained in:
@@ -225,6 +225,7 @@ function createWindow() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
global.API_PACKAGE = apiPackage;
|
global.API_PACKAGE = apiPackage;
|
||||||
|
global.NATIVE_MODULES = path.join(__dirname, 'nativeModules');
|
||||||
|
|
||||||
// console.log('global.API_PACKAGE', global.API_PACKAGE);
|
// console.log('global.API_PACKAGE', global.API_PACKAGE);
|
||||||
const api = require(apiPackage);
|
const api = require(apiPackage);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ const socket = require('../utility/socket');
|
|||||||
const { encryptConnection } = require('../utility/crypting');
|
const { encryptConnection } = require('../utility/crypting');
|
||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
|
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
function getNamedArgs() {
|
function getNamedArgs() {
|
||||||
const res = {};
|
const res = {};
|
||||||
for (let i = 0; i < process.argv.length; i++) {
|
for (let i = 0; i < process.argv.length; i++) {
|
||||||
@@ -140,7 +142,8 @@ module.exports = {
|
|||||||
'--is-forked-api',
|
'--is-forked-api',
|
||||||
'--start-process',
|
'--start-process',
|
||||||
'connectProcess',
|
'connectProcess',
|
||||||
...process.argv.slice(3),
|
...processArgs.getPassArgs(),
|
||||||
|
// ...process.argv.slice(3),
|
||||||
]);
|
]);
|
||||||
subprocess.on('message', resp => {
|
subprocess.on('message', resp => {
|
||||||
if (handleProcessCommunication(resp, subprocess)) return;
|
if (handleProcessCommunication(resp, subprocess)) return;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const requireEngineDriver = require('../utility/requireEngineDriver');
|
|||||||
const generateDeploySql = require('../shell/generateDeploySql');
|
const generateDeploySql = require('../shell/generateDeploySql');
|
||||||
const { createTwoFilesPatch } = require('diff');
|
const { createTwoFilesPatch } = require('diff');
|
||||||
const diff2htmlPage = require('../utility/diff2htmlPage');
|
const diff2htmlPage = require('../utility/diff2htmlPage');
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
||||||
@@ -78,7 +79,8 @@ module.exports = {
|
|||||||
'--is-forked-api',
|
'--is-forked-api',
|
||||||
'--start-process',
|
'--start-process',
|
||||||
'databaseConnectionProcess',
|
'databaseConnectionProcess',
|
||||||
...process.argv.slice(3),
|
...processArgs.getPassArgs(),
|
||||||
|
// ...process.argv.slice(3),
|
||||||
]);
|
]);
|
||||||
const lastClosed = this.closed[`${conid}/${database}`];
|
const lastClosed = this.closed[`${conid}/${database}`];
|
||||||
const newOpened = {
|
const newOpened = {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const { fork } = require('child_process');
|
|||||||
const { rundir, uploadsdir, pluginsdir, getPluginBackendPath, packagedPluginList } = require('../utility/directories');
|
const { rundir, uploadsdir, pluginsdir, getPluginBackendPath, packagedPluginList } = require('../utility/directories');
|
||||||
const { extractShellApiPlugins, extractShellApiFunctionName } = require('dbgate-tools');
|
const { extractShellApiPlugins, extractShellApiFunctionName } = require('dbgate-tools');
|
||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
function extractPlugins(script) {
|
function extractPlugins(script) {
|
||||||
const requireRegex = /\s*\/\/\s*@require\s+([^\s]+)\s*\n/g;
|
const requireRegex = /\s*\/\/\s*@require\s+([^\s]+)\s*\n/g;
|
||||||
@@ -98,15 +99,22 @@ module.exports = {
|
|||||||
const pluginNames = _.union(fs.readdirSync(pluginsdir()), packagedPluginList);
|
const pluginNames = _.union(fs.readdirSync(pluginsdir()), packagedPluginList);
|
||||||
console.log(`RUNNING SCRIPT ${scriptFile}`);
|
console.log(`RUNNING SCRIPT ${scriptFile}`);
|
||||||
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
||||||
const subprocess = fork(scriptFile, ['--checkParent', ...process.argv.slice(3)], {
|
const subprocess = fork(
|
||||||
cwd: directory,
|
scriptFile,
|
||||||
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
[
|
||||||
env: {
|
'--checkParent', // ...process.argv.slice(3)
|
||||||
...process.env,
|
...processArgs.getPassArgs(),
|
||||||
DBGATE_API: global['API_PACKAGE'] || global['dbgateApiModulePath'] || process.argv[1],
|
],
|
||||||
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, getPluginBackendPath(name)])),
|
{
|
||||||
},
|
cwd: directory,
|
||||||
});
|
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
DBGATE_API: global['API_PACKAGE'] || global['dbgateApiModulePath'] || process.argv[1],
|
||||||
|
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, getPluginBackendPath(name)])),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
const pipeDispatcher = severity => data =>
|
const pipeDispatcher = severity => data =>
|
||||||
this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const AsyncLock = require('async-lock');
|
|||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
const lock = new AsyncLock();
|
const lock = new AsyncLock();
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
opened: [],
|
opened: [],
|
||||||
@@ -41,7 +42,8 @@ module.exports = {
|
|||||||
'--is-forked-api',
|
'--is-forked-api',
|
||||||
'--start-process',
|
'--start-process',
|
||||||
'serverConnectionProcess',
|
'serverConnectionProcess',
|
||||||
...process.argv.slice(3),
|
...processArgs.getPassArgs(),
|
||||||
|
// ...process.argv.slice(3),
|
||||||
]);
|
]);
|
||||||
const newOpened = {
|
const newOpened = {
|
||||||
conid,
|
conid,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const socket = require('../utility/socket');
|
|||||||
const { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
const jsldata = require('./jsldata');
|
const jsldata = require('./jsldata');
|
||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @type {import('dbgate-types').OpenedSession[]} */
|
/** @type {import('dbgate-types').OpenedSession[]} */
|
||||||
@@ -69,7 +70,8 @@ module.exports = {
|
|||||||
'--is-forked-api',
|
'--is-forked-api',
|
||||||
'--start-process',
|
'--start-process',
|
||||||
'sessionProcess',
|
'sessionProcess',
|
||||||
...process.argv.slice(3),
|
...processArgs.getPassArgs(),
|
||||||
|
// ...process.argv.slice(3),
|
||||||
]);
|
]);
|
||||||
const newOpened = {
|
const newOpened = {
|
||||||
conid,
|
conid,
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
const argIndex = process.argv.indexOf('--native-modules');
|
const argIndex = process.argv.indexOf('--native-modules');
|
||||||
const redirectFile = argIndex > 0 ? process.argv[argIndex + 1] : null;
|
const redirectFile = argIndex > 0 ? process.argv[argIndex + 1] : null;
|
||||||
|
|
||||||
// @ts-ignore
|
function requireDynamic(file) {
|
||||||
module.exports = redirectFile ? __non_webpack_require__(redirectFile) : require('./nativeModulesContent');
|
try {
|
||||||
|
// @ts-ignore
|
||||||
|
return __non_webpack_require__(redirectFile);
|
||||||
|
} catch (err) {
|
||||||
|
return require(redirectFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = redirectFile ? requireDynamic(redirectFile) : require('./nativeModulesContent');
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
const uuidv1 = require('uuid/v1');
|
const uuidv1 = require('uuid/v1');
|
||||||
const { handleProcessCommunication } = require('./processComm');
|
const { handleProcessCommunication } = require('./processComm');
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
|
|
||||||
class DatastoreProxy {
|
class DatastoreProxy {
|
||||||
constructor(file) {
|
constructor(file) {
|
||||||
@@ -33,7 +34,8 @@ class DatastoreProxy {
|
|||||||
'--is-forked-api',
|
'--is-forked-api',
|
||||||
'--start-process',
|
'--start-process',
|
||||||
'jslDatastoreProcess',
|
'jslDatastoreProcess',
|
||||||
...process.argv.slice(3),
|
...processArgs.getPassArgs(),
|
||||||
|
// ...process.argv.slice(3),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.subprocess.on('message', message => {
|
this.subprocess.on('message', message => {
|
||||||
|
|||||||
@@ -7,13 +7,17 @@ function getNamedArg(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkParent = process.argv.includes('--checkParent');
|
const checkParent = process.argv.includes('--checkParent');
|
||||||
const nativeModules = getNamedArg('--native-modules');
|
|
||||||
const startProcess = getNamedArg('--start-process');
|
const startProcess = getNamedArg('--start-process');
|
||||||
const isForkedApi = process.argv.includes('--is-forked-api');
|
const isForkedApi = process.argv.includes('--is-forked-api');
|
||||||
|
|
||||||
|
function getPassArgs() {
|
||||||
|
if (global['NATIVE_MODULES']) return ['--native-modules', global['NATIVE_MODULES']];
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkParent,
|
checkParent,
|
||||||
nativeModules,
|
|
||||||
startProcess,
|
startProcess,
|
||||||
isForkedApi,
|
isForkedApi,
|
||||||
|
getPassArgs,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user