diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-24 15:01:01 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-24 15:01:01 +0200 |
| commit | 4fc6b8d6ed1857f5952cd10a5fb75daaf41282d1 (patch) | |
| tree | 3f821bbb0867a0d5e5cfc2ff1222d0f049785917 | |
| parent | 50622ef2b084aef517cae4d30eefae3b12ff72de (diff) | |
| download | processor-4fc6b8d6ed1857f5952cd10a5fb75daaf41282d1.tar.gz processor-4fc6b8d6ed1857f5952cd10a5fb75daaf41282d1.zip | |
support queue name via env var
| -rw-r--r-- | worker.js | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -13,6 +13,7 @@ const amqp = require("amqplib"), const RABBITMQ_URI = process.env.RABBITMQ_URI, DATABASE_URI = process.env.DATABASE_URI, + QUEUE = process.env.QUEUE || "process", LOGGLY_TOKEN = process.env.LOGGLY_TOKEN, // matches + players, 5 players with 50 matches as default BATCHSIZE = parseInt(process.env.BATCHSIZE) || 5 * (50 + 1), @@ -36,7 +37,7 @@ if (LOGGLY_TOKEN) logger.add(winston.transports.Loggly, { inputToken: LOGGLY_TOKEN, subdomain: "kvahuja", - tags: ["backend", "processor"], + tags: ["backend", "processor", QUEUE], json: true }); @@ -91,7 +92,7 @@ function flatten(obj) { }); rabbit = await amqp.connect(RABBITMQ_URI, { heartbeat: 120 }); ch = await rabbit.createChannel(); - await ch.assertQueue("process", {durable: true}); + await ch.assertQueue(QUEUE, {durable: true}); break; } catch (err) { logger.error("Error connecting", err); @@ -100,7 +101,7 @@ function flatten(obj) { } model = require("../orm/model")(seq, Seq); - //await seq.sync({ force: true }); + //await seq.sync(); let load_timer = undefined, idle_timer = undefined, @@ -145,7 +146,7 @@ function flatten(obj) { match_data = new Set(), msg_buffer = new Set(); - ch.consume("process", async (msg) => { + ch.consume(QUEUE, async (msg) => { if (msg.properties.type == "player") { // apigrabber sends an array player_data.add(...JSON.parse(msg.content)); |
