Fix stats queue

dev
Thomas Lynch 12 months ago
parent 0552088f13
commit 5b1e386934
  1. 2
      healthcheck/worker.js
  2. 2
      redis.js
  3. 4
      stats/main.js
  4. 5
      stats/worker.js

@ -78,7 +78,7 @@ async function doCheck(domainKey, hkey, record) {
console.info('fetch()ed health:', domainKey, hkey, record.ip, recordHealth); console.info('fetch()ed health:', domainKey, hkey, record.ip, recordHealth);
} else { } else {
recordHealth = recordHealth.toString(); recordHealth = recordHealth.toString();
console.log('cached health:', domainKey, hkey, record.ip, recordHealth); // console.log('cached health:', domainKey, hkey, record.ip, recordHealth);
} }
if (recordHealth === '1') { if (recordHealth === '1') {
record.u = true; record.u = true;

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
await dotenv.config({ path: '.env' }); dotenv.config({ path: '.env' });
import Redis from 'ioredis';; import Redis from 'ioredis';;

@ -5,11 +5,11 @@ process
.on('unhandledRejection', console.error); .on('unhandledRejection', console.error);
import dotenv from 'dotenv'; import dotenv from 'dotenv';
await dotenv.config({ path: '.env' }); dotenv.config({ path: '.env' });
import Queue from 'bull'; import Queue from 'bull';
const haproxyStatsQueue = new Queue('stats', { w: { const haproxyStatsQueue = new Queue('stats', { redis: {
host: process.env.REDIS_HOST || '127.0.0.1', host: process.env.REDIS_HOST || '127.0.0.1',
port: process.env.REDIS_PORT || 6379, port: process.env.REDIS_PORT || 6379,
password: process.env.REDIS_PASS || '', password: process.env.REDIS_PASS || '',

@ -5,9 +5,8 @@ process
.on('unhandledRejection', console.error); .on('unhandledRejection', console.error);
import dotenv from 'dotenv'; import dotenv from 'dotenv';
await dotenv.config({ path: '.env' }); dotenv.config({ path: '.env' });
import * as redlock from '../redlock.js';
import Queue from 'bull'; import Queue from 'bull';
const haproxyStatsQueue = new Queue('stats', { redis: { const haproxyStatsQueue = new Queue('stats', { redis: {
host: process.env.REDIS_HOST || '127.0.0.1', host: process.env.REDIS_HOST || '127.0.0.1',
@ -97,7 +96,6 @@ async function getFormattedStats(host) {
}; };
async function processHost(host) { async function processHost(host) {
console.log(host)
try { try {
const hostname = new URL(host).hostname; const hostname = new URL(host).hostname;
const { frontendStats, serverStats } = await getFormattedStats(host); const { frontendStats, serverStats } = await getFormattedStats(host);
@ -142,7 +140,6 @@ async function processHost(host) {
}; };
async function handleJob(job, done) { async function handleJob(job, done) {
console.log('handleJob')
const { hosts } = job.data; const { hosts } = job.data;
hosts.forEach(processHost); hosts.forEach(processHost);
done(); done();

Loading…
Cancel
Save