v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
import * as Deque from 'double-ended-queue';
|
||||
import Xev from 'xev';
|
||||
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../queue';
|
||||
import { deliverQueue, inboxQueue } from '../queue';
|
||||
|
||||
const ev = new Xev();
|
||||
|
||||
const interval = 3000;
|
||||
const interval = 10000;
|
||||
|
||||
/**
|
||||
* Report queue stats regularly
|
||||
*/
|
||||
export default function() {
|
||||
const log = new Deque<any>();
|
||||
const log = [] as any[];
|
||||
|
||||
ev.on('requestQueueStatsLog', x => {
|
||||
ev.emit(`queueStatsLog:${x.id}`, log.toArray().slice(0, x.length || 50));
|
||||
ev.emit(`queueStatsLog:${x.id}`, log.slice(0, x.length || 50));
|
||||
});
|
||||
|
||||
let activeDeliverJobs = 0;
|
||||
let activeInboxJobs = 0;
|
||||
let activeDbJobs = 0;
|
||||
let activeObjectStorageJobs = 0;
|
||||
|
||||
deliverQueue.on('global:active', () => {
|
||||
activeDeliverJobs++;
|
||||
@@ -29,19 +26,9 @@ export default function() {
|
||||
activeInboxJobs++;
|
||||
});
|
||||
|
||||
dbQueue.on('global:active', () => {
|
||||
activeDbJobs++;
|
||||
});
|
||||
|
||||
objectStorageQueue.on('global:active', () => {
|
||||
activeObjectStorageJobs++;
|
||||
});
|
||||
|
||||
async function tick() {
|
||||
const deliverJobCounts = await deliverQueue.getJobCounts();
|
||||
const inboxJobCounts = await inboxQueue.getJobCounts();
|
||||
const dbJobCounts = await dbQueue.getJobCounts();
|
||||
const objectStorageJobCounts = await objectStorageQueue.getJobCounts();
|
||||
|
||||
const stats = {
|
||||
deliver: {
|
||||
@@ -56,18 +43,6 @@ export default function() {
|
||||
waiting: inboxJobCounts.waiting,
|
||||
delayed: inboxJobCounts.delayed
|
||||
},
|
||||
db: {
|
||||
activeSincePrevTick: activeDbJobs,
|
||||
active: dbJobCounts.active,
|
||||
waiting: dbJobCounts.waiting,
|
||||
delayed: dbJobCounts.delayed
|
||||
},
|
||||
objectStorage: {
|
||||
activeSincePrevTick: activeObjectStorageJobs,
|
||||
active: objectStorageJobCounts.active,
|
||||
waiting: objectStorageJobCounts.waiting,
|
||||
delayed: objectStorageJobCounts.delayed
|
||||
},
|
||||
};
|
||||
|
||||
ev.emit('queueStats', stats);
|
||||
@@ -77,8 +52,6 @@ export default function() {
|
||||
|
||||
activeDeliverJobs = 0;
|
||||
activeInboxJobs = 0;
|
||||
activeDbJobs = 0;
|
||||
activeObjectStorageJobs = 0;
|
||||
}
|
||||
|
||||
tick();
|
||||
|
Reference in New Issue
Block a user