From 98cf7958cb42219579fa3b624f41d567b82b5a4e Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 30 May 2017 10:34:23 +0200 Subject: add go SLOWMODE :) --- worker.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/worker.js b/worker.js index 0934392..54988d9 100644 --- a/worker.js +++ b/worker.js @@ -26,7 +26,9 @@ const RABBITMQ_URI = process.env.RABBITMQ_URI, MAXCONNS = parseInt(process.env.MAXCONNS) || 3, // number of participants to calculate at once BATCHSIZE = parseInt(process.env.BATCHSIZE) || 1000, - LOAD_TIMEOUT = parseInt(process.env.LOAD_TIMEOUT) || 5; // s + LOAD_TIMEOUT = parseInt(process.env.LOAD_TIMEOUT) || 5, // s + // wait time before next batch + SLOWMODE = parseInt(process.env.SLOWMODE) || 0; // s const logger = new (winston.Logger)({ transports: [ @@ -137,6 +139,10 @@ if (LOGGLY_TOKEN) type: seq.QueryTypes.UPSERT }); + if (SLOWMODE > 0) { + logger.info("slowmode active, sleeping…", { wait: SLOWMODE }); + await sleep(SLOWMODE * 1000); + } // ack await Promise.map(msgs, async (m) => await ch.ack(m)); // notify web -- cgit v1.3.1