env fixes and add debug logs

dev
Thomas Lynch 10 months ago
parent 8f89897ae5
commit 0552088f13
  1. 9
      agent.js
  2. 3
      redis.js
  3. 2
      server.js
  4. 2
      stats/main.js
  5. 3
      stats/worker.js

@ -7,19 +7,20 @@ const agentOptions = {
};
if (process.env.PINNED_FP) {
// console.log('Pinned fingerprint:', process.env.PINNED_FP);
console.log('Pinned fingerprint:', process.env.PINNED_FP);
agentOptions.checkServerIdentity = (_host, cert) => {
//TODO: host verification? e.g. tls.checkServerIdentity(host, cert);
// console.log('Checking:', cert.fingerprint256);
console.log('Checking:', cert.fingerprint256);
if (process.env.PINNED_FP !== cert.fingerprint256) {
return new Error('Certificate not pinned');
}
};
}
import fs from 'fs';
if (process.env.CUSTOM_CA_PATH) {
// console.log('Private CA file path:', process.env.CUSTOM_CA_PATH);
agentOptions.ca = require('fs').readFileSync(process.env.CUSTOM_CA_PATH);
console.log('Private CA file path:', process.env.CUSTOM_CA_PATH);
agentOptions.ca = fs.readFileSync(process.env.CUSTOM_CA_PATH);
}
const agent = new https.Agent(agentOptions);

@ -1,5 +1,8 @@
'use strict';
import dotenv from 'dotenv';
await dotenv.config({ path: '.env' });
import Redis from 'ioredis';;
export const client = new Redis({

@ -5,7 +5,7 @@ process
.on('unhandledRejection', console.error);
import dotenv from 'dotenv';
dotenv.config({ path: '.env' });
await dotenv.config({ path: '.env' });
import express from 'express';
import next from 'next';

@ -29,7 +29,7 @@ async function main() {
clusterUrls.forEach(cu => {
//group to a certain amount in each array? ehh probs not
haproxyStatsQueue.add({ hosts: [cu] }, { removeOnComplete: true });
})
});
} catch(e) {
console.error(e);
}

@ -97,6 +97,7 @@ async function getFormattedStats(host) {
};
async function processHost(host) {
console.log(host)
try {
const hostname = new URL(host).hostname;
const { frontendStats, serverStats } = await getFormattedStats(host);
@ -141,10 +142,10 @@ async function processHost(host) {
};
async function handleJob(job, done) {
console.log('handleJob')
const { hosts } = job.data;
hosts.forEach(processHost);
done();
}
haproxyStatsQueue.process(handleJob);

Loading…
Cancel
Save