fix: add gsc worker to bullboard
This commit is contained in:
@@ -5,6 +5,7 @@ import { createInitialSalts } from '@openpanel/db';
|
|||||||
import {
|
import {
|
||||||
cronQueue,
|
cronQueue,
|
||||||
eventsGroupQueues,
|
eventsGroupQueues,
|
||||||
|
gscQueue,
|
||||||
importQueue,
|
importQueue,
|
||||||
insightsQueue,
|
insightsQueue,
|
||||||
miscQueue,
|
miscQueue,
|
||||||
@@ -12,9 +13,8 @@ import {
|
|||||||
sessionsQueue,
|
sessionsQueue,
|
||||||
} from '@openpanel/queue';
|
} from '@openpanel/queue';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import client from 'prom-client';
|
|
||||||
|
|
||||||
import { BullBoardGroupMQAdapter } from 'groupmq';
|
import { BullBoardGroupMQAdapter } from 'groupmq';
|
||||||
|
import client from 'prom-client';
|
||||||
import sourceMapSupport from 'source-map-support';
|
import sourceMapSupport from 'source-map-support';
|
||||||
import { bootCron } from './boot-cron';
|
import { bootCron } from './boot-cron';
|
||||||
import { bootWorkers } from './boot-workers';
|
import { bootWorkers } from './boot-workers';
|
||||||
@@ -39,7 +39,7 @@ async function start() {
|
|||||||
createBullBoard({
|
createBullBoard({
|
||||||
queues: [
|
queues: [
|
||||||
...eventsGroupQueues.map(
|
...eventsGroupQueues.map(
|
||||||
(queue) => new BullBoardGroupMQAdapter(queue) as any,
|
(queue) => new BullBoardGroupMQAdapter(queue) as any
|
||||||
),
|
),
|
||||||
new BullMQAdapter(sessionsQueue),
|
new BullMQAdapter(sessionsQueue),
|
||||||
new BullMQAdapter(cronQueue),
|
new BullMQAdapter(cronQueue),
|
||||||
@@ -47,8 +47,9 @@ async function start() {
|
|||||||
new BullMQAdapter(miscQueue),
|
new BullMQAdapter(miscQueue),
|
||||||
new BullMQAdapter(importQueue),
|
new BullMQAdapter(importQueue),
|
||||||
new BullMQAdapter(insightsQueue),
|
new BullMQAdapter(insightsQueue),
|
||||||
|
new BullMQAdapter(gscQueue),
|
||||||
],
|
],
|
||||||
serverAdapter: serverAdapter,
|
serverAdapter,
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use('/', serverAdapter.getRouter());
|
app.use('/', serverAdapter.getRouter());
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
import { db, syncGscData } from '@openpanel/db';
|
import { db, syncGscData } from '@openpanel/db';
|
||||||
import { gscQueue } from '@openpanel/queue';
|
|
||||||
import type { GscQueuePayload } from '@openpanel/queue';
|
import type { GscQueuePayload } from '@openpanel/queue';
|
||||||
|
import { gscQueue } from '@openpanel/queue';
|
||||||
import type { Job } from 'bullmq';
|
import type { Job } from 'bullmq';
|
||||||
import { logger } from '../utils/logger';
|
import { logger } from '../utils/logger';
|
||||||
|
|
||||||
const BACKFILL_MONTHS = 6;
|
const BACKFILL_MONTHS = 6;
|
||||||
const CHUNK_DAYS = 14;
|
const CHUNK_DAYS = 14;
|
||||||
|
|
||||||
export async function gscJob(job: Job<GscQueuePayload>) {
|
export function gscJob(job: Job<GscQueuePayload>) {
|
||||||
switch (job.data.type) {
|
switch (job.data.type) {
|
||||||
case 'gscProjectSync':
|
case 'gscProjectSync':
|
||||||
return gscProjectSyncJob(job.data.payload.projectId);
|
return gscProjectSyncJob(job.data.payload.projectId);
|
||||||
case 'gscProjectBackfill':
|
case 'gscProjectBackfill':
|
||||||
return gscProjectBackfillJob(job.data.payload.projectId);
|
return gscProjectBackfillJob(job.data.payload.projectId);
|
||||||
|
default:
|
||||||
|
throw new Error('Unknown GSC job type');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +61,9 @@ async function gscProjectSyncJob(projectId: string) {
|
|||||||
async function gscProjectBackfillJob(projectId: string) {
|
async function gscProjectBackfillJob(projectId: string) {
|
||||||
const conn = await db.gscConnection.findUnique({ where: { projectId } });
|
const conn = await db.gscConnection.findUnique({ where: { projectId } });
|
||||||
if (!conn?.siteUrl) {
|
if (!conn?.siteUrl) {
|
||||||
logger.warn('GSC backfill skipped: no connection or siteUrl', { projectId });
|
logger.warn('GSC backfill skipped: no connection or siteUrl', {
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user