diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-25 14:29:43 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-25 14:29:43 +0200 |
| commit | 506ad32a251f95fd950596a3efb0c595485613b7 (patch) | |
| tree | f05993938175026bcd8f17e00fb597976d635431 | |
| parent | f2bdd5c9c41796f1887eea94576de67af6bc88e0 (diff) | |
| download | cruncher-506ad32a251f95fd950596a3efb0c595485613b7.tar.gz cruncher-506ad32a251f95fd950596a3efb0c595485613b7.zip | |
allow queue configuration via env var
| -rw-r--r-- | worker.js | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -20,6 +20,7 @@ const amqp = require("amqplib"), const RABBITMQ_URI = process.env.RABBITMQ_URI, DATABASE_URI = process.env.DATABASE_URI, + QUEUE = process.env.QUEUE || "crunch", LOGGLY_TOKEN = process.env.LOGGLY_TOKEN, // size of connection pool MAXCONNS = parseInt(process.env.MAXCONNS) || 3, @@ -41,7 +42,7 @@ if (LOGGLY_TOKEN) logger.add(winston.transports.Loggly, { inputToken: LOGGLY_TOKEN, subdomain: "kvahuja", - tags: ["backend", "cruncher"], + tags: ["backend", "cruncher", QUEUE], json: true }); @@ -58,7 +59,7 @@ if (LOGGLY_TOKEN) }), rabbit = await amqp.connect(RABBITMQ_URI, { heartbeat: 320 }), ch = await rabbit.createChannel(); - await ch.assertQueue("crunch", {durable: true}); + await ch.assertQueue(QUEUE, {durable: true}); break; } catch (err) { logger.error("Error connecting", err); @@ -83,7 +84,7 @@ if (LOGGLY_TOKEN) // set maximum allowed number of unacked msgs // TODO maybe split queues by type await ch.prefetch(BATCHSIZE); - ch.consume("crunch", (msg) => { + ch.consume(QUEUE, (msg) => { const api_id = msg.content.toString(); if (msg.properties.type == "global") participants_global.add(api_id); |
