From ae69ca9ebd8bfdd103f45cd421ea31a6499925c9 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 12 Jun 2022 19:42:51 +0200 Subject: [PATCH] explicit start api --- docker/entrypoint.sh | 2 +- packages/api/package.json | 10 +++++----- packages/api/src/index.js | 5 +++-- packages/api/src/utility/processArgs.js | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index afc164e0..140e3acc 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -8,4 +8,4 @@ then echo "$HOST_IP $HOST_DOMAIN" >> /etc/hosts fi -node bundle.js +node bundle.js --start-api diff --git a/packages/api/package.json b/packages/api/package.json index 3577e95e..4480fef0 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -52,11 +52,11 @@ "uuid": "^3.4.0" }, "scripts": { - "start": "env-cmd node src/index.js", - "start:portal": "env-cmd -f env/portal/.env node src/index.js", - "start:singledb": "env-cmd -f env/singledb/.env node src/index.js", - "start:filedb": "env-cmd node src/index.js /home/jena/test/chinook/Chinook.db", - "start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test", + "start": "env-cmd node src/index.js --start-api", + "start:portal": "env-cmd -f env/portal/.env node src/index.js --start-api", + "start:singledb": "env-cmd -f env/singledb/.env node src/index.js --start-api", + "start:filedb": "env-cmd node src/index.js /home/jena/test/chinook/Chinook.db --start-api", + "start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test --start-api", "ts": "tsc", "build": "webpack" }, diff --git a/packages/api/src/index.js b/packages/api/src/index.js index b93feeb9..a8ea4620 100644 --- a/packages/api/src/index.js +++ b/packages/api/src/index.js @@ -8,9 +8,10 @@ if (processArgs.startProcess) { const proc = require('./proc'); const module = proc[processArgs.startProcess]; module.start(); -} else if (!processArgs.checkParent && !global['API_PACKAGE']) { - const main = require('./main'); +} +if (processArgs.startApi) { + const main = require('./main'); main.start(); } diff --git a/packages/api/src/utility/processArgs.js b/packages/api/src/utility/processArgs.js index 3b5dc2c5..f3bc07e5 100644 --- a/packages/api/src/utility/processArgs.js +++ b/packages/api/src/utility/processArgs.js @@ -11,6 +11,7 @@ const startProcess = getNamedArg('--start-process'); const isForkedApi = process.argv.includes('--is-forked-api'); const pluginsDir = getNamedArg('--plugins-dir'); const workspaceDir = getNamedArg('--workspace-dir'); +const startApi = process.argv.includes('--start-api'); function getPassArgs() { const res = []; @@ -30,4 +31,5 @@ module.exports = { getPassArgs, pluginsDir, workspaceDir, + startApi, };