Skip to content

Commit

Permalink
feat: custom agent config
Browse files Browse the repository at this point in the history
  • Loading branch information
avwo committed Sep 2, 2022
1 parent 4643268 commit 86fc56b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,10 @@ exports.extend = function (newConf) {
newConf.mode = process.env.WHISTLE_MODE + '|' + (newConf.mode || '');
}
var useAgent;
var newAgentConf;
if (newConf) {
config.uiMiddleware = newConf.uiMiddlewares || newConf.uiMiddleware;
newAgentConf = newConf.agentConfig;
if (newConf.cmdName && CMD_RE.test(newConf.cmdName)) {
config.cmdName = newConf.cmdName;
}
Expand Down Expand Up @@ -1041,14 +1043,14 @@ exports.extend = function (newConf) {
if (config.strict) {
config.sockets = Math.max(config.sockets, 360);
}
var agentConfig = {
var agentConfig = newAgentConf || {
maxSockets: config.sockets,
keepAlive: true,
keepAliveMsecs: KEEP_ALIVE_MSECS,
maxFreeSockets: 0
};
// node 11及以上版本缓存连接有问题,先禁掉
disableAgent = !useAgent && (disableAgent || config.debug);
disableAgent = !newAgentConf && !useAgent && (disableAgent || config.debug);
config.httpAgent = disableAgent ? false : createAgent(agentConfig);
config.httpsAgent = disableAgent ? false : createAgent(agentConfig, true);
config.getSocksAgent = function (options) {
Expand Down

0 comments on commit 86fc56b

Please sign in to comment.