diff --git a/msa/js-executor/docker/start-js-executor.sh b/msa/js-executor/docker/start-js-executor.sh index 804b93da84..575f93c389 100755 --- a/msa/js-executor/docker/start-js-executor.sh +++ b/msa/js-executor/docker/start-js-executor.sh @@ -26,4 +26,5 @@ source "${CONF_FOLDER}/${configfile}" cd ${pkg.installFolder} -exec /bin/sh -c "node server.js" +# This will forward this PID 1 to the node.js and forward SIGTERM for graceful shutdown as well +exec node server.js diff --git a/msa/js-executor/package.json b/msa/js-executor/package.json index 1ad1f98769..1d1059aa90 100644 --- a/msa/js-executor/package.json +++ b/msa/js-executor/package.json @@ -8,8 +8,8 @@ "scripts": { "pkg": "tsc && pkg -t node16-linux-x64,node16-win-x64 --out-path ./target ./target/src && node install.js", "test": "echo \"Error: no test specified\" && exit 1", - "start": "nodemon --watch '.' --ext 'ts' --exec 'WEB_FOLDER=./target/web ts-node server.ts'", - "start-prod": "nodemon --watch '.' --ext 'ts' --exec 'WEB_FOLDER=./target/web NODE_ENV=production ts-node server.ts'", + "start": "nodemon --watch '.' --ext 'ts' --exec 'ts-node server.ts'", + "start-prod": "nodemon --watch '.' --ext 'ts' --exec 'NODE_ENV=production ts-node server.ts'", "build": "tsc" }, "dependencies": { diff --git a/msa/js-executor/server.ts b/msa/js-executor/server.ts index 49476c2f44..3d59d7fe00 100644 --- a/msa/js-executor/server.ts +++ b/msa/js-executor/server.ts @@ -71,7 +71,8 @@ let httpServer: HttpServer; })(); process.on('SIGTERM', () => { - process.exit(); + logger.info('SIGTERM signal received'); + process.exit(0); }); process.on('exit', async () => { @@ -81,5 +82,5 @@ process.on('exit', async () => { if (queues) { queues.exit(0); } + logger.info('JavaScript Executor Microservice has been stopped.'); }); -