From dd51c591ef7ae899a5618c4db050f81e51643cfd Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Thu, 28 May 2020 20:39:30 +0800 Subject: [PATCH] Support enabling/disabling the agent via env var (#114) --- modules/nodejs-agent/lib/agent.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/nodejs-agent/lib/agent.js b/modules/nodejs-agent/lib/agent.js index 2a69669..bed673c 100644 --- a/modules/nodejs-agent/lib/agent.js +++ b/modules/nodejs-agent/lib/agent.js @@ -33,6 +33,10 @@ function Agent() { } Agent.prototype.start = function(agentOptions) { + if (!!process.env.SW_ENABLED && process.env.SW_ENABLED !== "true") { + console.info("SW_ENABLED != true, the agent won't start"); + return; + } AgentConfig.initConfig(agentOptions); serviceManager.launch(); @@ -45,7 +49,7 @@ Agent.prototype.start = function(agentOptions) { function(originModule, moduleName, version, enhanceFile) { let intercept = _pluginManager.attemptToFindInterceptor(moduleName, version, enhanceFile); - if (intercept == undefined) { + if (intercept === undefined) { return originModule; } -- GitLab