Skip to content

Commit 8c8ae4f

Browse files
committed
apm-1717: remove agent keepalive from sync-wrap
1 parent 707c314 commit 8c8ae4f

4 files changed

Lines changed: 7 additions & 60 deletions

File tree

docker/sync-wrap/package-lock.json

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/sync-wrap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"author": "",
1010
"license": "",
1111
"dependencies": {
12-
"agentkeepalive": "^4.1.3",
1312
"express": "^5.0.0-alpha.8",
1413
"loglevel": "^1.7.1",
1514
"uuid": "^8.3.2"

docker/sync-wrap/src/app.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,29 @@ const uuid = require('uuid');
88
function setup(options) {
99
options = options || {};
1010
app.locals.app_name = options.APP_NAME || 'sync-wrap';
11-
app.locals.upstream = new URL(options.UPSTREAM || "http://localhost");
11+
app.locals.upstream = new URL(options.UPSTREAM || "http://localhost:9003");
1212
app.locals.version_info = JSON.parse(options.VERSION_INFO || '{}');
1313
app.locals.base_path = app.locals.upstream.pathname === "/" ? "" : app.locals.upstream.pathname;
1414
log.setLevel(options.LOG_LEVEL || "info");
1515
app.locals.allow_insecure = (options.ALLOW_INSECURE || "false") === "true";
1616
app.locals.unbotli = (options.UNBOTLI || "false") === "true";
1717
app.locals.max_sleep = parseFloat(options.MAX_SLEEP || 5);
1818
app.locals.default_syncwait = parseFloat(options.DEFAULT_SYNCWAIT || 5);
19-
let keepalive = (options.KEEPALIVE || "true") === "true";
2019

2120
let https = app.locals.upstream.protocol === "https:";
2221

22+
app.locals.conn = https ? require("https") : require("http");
2323

2424
let default_options = {
2525
host: app.locals.upstream.hostname,
2626
port: app.locals.upstream.port
2727
};
2828

29-
if (keepalive) {
30-
let Agent = https ? require("agentkeepalive").HttpsAgent : require("agentkeepalive");
31-
default_options.agent = new Agent({
32-
maxSockets: 1000,
33-
maxFreeSockets: 100,
34-
timeout: 900000, // active socket keepalive for 15 mins ?
35-
freeSocketTimeout: 30000 // free socket keepalive for 30 seconds
36-
});
37-
}
38-
3929
if (app.locals.allow_insecure) {
4030
default_options.rejectUnauthorized = false;
4131
}
4232

4333
app.locals.default_options = default_options;
44-
app.locals.conn = https ? require("https") : require("http");
4534

4635
log.info(JSON.stringify({
4736
timestamp: Date.now(),
@@ -109,11 +98,6 @@ function after_request(req, res, next) {
10998
version: app.locals.version_info
11099
};
111100

112-
if (req.path === "/_status") {
113-
let agent = req.app.locals.default_options.agent;
114-
log_entry.agent_status = agent.getCurrentStatus();
115-
}
116-
117101
if (log.getLevel()<2) {
118102
// debug
119103
log_entry.req.headers = (req.rawHeaders || []).asMultiValue();

docker/sync-wrap/src/handlers.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
const log = require("loglevel");
44
const querystring = require("querystring");
5-
const util = require("util");
65
const stream = require("stream");
7-
const pipeline = util.promisify(stream.pipeline);
6+
const { promisify } = require('util')
7+
const pipeline = promisify(stream.pipeline);
8+
const sleep = promisify(setTimeout)
89
const zlib = require("zlib");
910

1011

@@ -241,11 +242,7 @@ const lazy_log = (res, log_level, options = {}) => {
241242
log[log_level](JSON.stringify(log_line))
242243
};
243244

244-
const sleep = (delay) => {
245-
return new Promise(resolve => {
246-
setTimeout(resolve, delay)
247-
});
248-
};
245+
249246

250247
function ping_response(req) {
251248
return {
@@ -264,7 +261,7 @@ async function ping(req, res, next) {
264261
}
265262

266263
async function status(req, res, next) {
267-
res.locals.status = true;
264+
res.locals.handled = true;
268265

269266
let response = ping_response(req);
270267

0 commit comments

Comments
 (0)