Skip to content

Commit

Permalink
Merge pull request #7613 from YevhenBondarenko/feature/js-executor-im…
Browse files Browse the repository at this point in the history
…provements

[3.4.2] js-executor improvements
  • Loading branch information
ashvayka committed Nov 14, 2022
2 parents b02a221 + 11bd9b5 commit 1d2097d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docker/tb-js-executor.env
Expand Up @@ -3,4 +3,5 @@ LOGGER_LEVEL=info
LOG_FOLDER=logs
LOGGER_FILENAME=tb-js-executor-%DATE%.log
DOCKER_MODE=true
SCRIPT_BODY_TRACE_FREQUENCY=1000
SCRIPT_BODY_TRACE_FREQUENCY=1000
NODE_OPTIONS="--max-old-space-size=200"
5 changes: 5 additions & 0 deletions msa/js-executor/api/jsInvokeMessageProcessor.ts
Expand Up @@ -39,6 +39,7 @@ const TIMEOUT_ERROR = 2;
const NOT_FOUND_ERROR = 3;

const statFrequency = Number(config.get('script.stat_print_frequency'));
const memoryUsageTraceFrequency = Number(config.get('script.memory_usage_trace_frequency'));
const scriptBodyTraceFrequency = Number(config.get('script.script_body_trace_frequency'));
const useSandbox = config.get('script.use_sandbox') === 'true';
const maxActiveScripts = Number(config.get('script.max_active_scripts'));
Expand Down Expand Up @@ -167,6 +168,10 @@ export class JsInvokeMessageProcessor {
if (this.executedScriptsCounter % scriptBodyTraceFrequency == 0) {
this.logger.info('[%s] Executing script body: [%s]', scriptId, invokeRequest.scriptBody);
}
if (this.executedScriptsCounter % memoryUsageTraceFrequency == 0) {
this.logger.info('Current memory usage: [%s]', process.memoryUsage());
}

this.getOrCompileScript(scriptId, invokeRequest.scriptBody).then(
(script) => {
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
Expand Down
1 change: 1 addition & 0 deletions msa/js-executor/config/custom-environment-variables.yml
Expand Up @@ -75,6 +75,7 @@ logger:

script:
use_sandbox: "SCRIPT_USE_SANDBOX"
memory_usage_trace_frequency: "MEMORY_USAGE_TRACE_FREQUENCY"
stat_print_frequency: "SCRIPT_STAT_PRINT_FREQUENCY"
script_body_trace_frequency: "SCRIPT_BODY_TRACE_FREQUENCY"
max_active_scripts: "MAX_ACTIVE_SCRIPTS"
Expand Down
1 change: 1 addition & 0 deletions msa/js-executor/config/default.yml
Expand Up @@ -64,6 +64,7 @@ logger:

script:
use_sandbox: "true"
memory_usage_trace_frequency: "1000"
script_body_trace_frequency: "10000"
stat_print_frequency: "10000"
max_active_scripts: "1000"
Expand Down
2 changes: 1 addition & 1 deletion msa/js-executor/docker/start-js-executor.sh
Expand Up @@ -27,4 +27,4 @@ source "${CONF_FOLDER}/${configfile}"
cd ${pkg.installFolder}

# This will forward this PID 1 to the node.js and forward SIGTERM for graceful shutdown as well
exec node server.js
exec --no-compilation-cache node server.js

0 comments on commit 1d2097d

Please sign in to comment.