X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fserver%2Fdebug.ts;h=e09510dc3754cfb08657dcb03a1da188a91aba53;hb=ac907dc7c158056e9b6a5cb58acd27df5c7c2670;hp=a6e9147f3c170c984af1066d478a61d108674d12;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts index a6e9147f3..e09510dc3 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/controllers/api/server/debug.ts @@ -1,8 +1,10 @@ +import express from 'express' import { InboxManager } from '@server/lib/activitypub/inbox-manager' import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' -import { SendDebugCommand } from '@shared/models' -import * as express from 'express' +import { VideoViewsBufferScheduler } from '@server/lib/schedulers/video-views-buffer-scheduler' +import { VideoViewsManager } from '@server/lib/views/video-views-manager' +import { Debug, SendDebugCommand } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserRight } from '../../../../shared/models/users' import { authenticate, ensureUserHasRight } from '../../../middlewares' @@ -32,15 +34,19 @@ function getDebug (req: express.Request, res: express.Response) { return res.json({ ip: req.ip, activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting() - }) + } as Debug) } async function runCommand (req: express.Request, res: express.Response) { const body: SendDebugCommand = req.body - if (body.command === 'remove-dandling-resumable-uploads') { - await RemoveDanglingResumableUploadsScheduler.Instance.execute() + const processors: { [id in SendDebugCommand['command']]: () => Promise } = { + 'remove-dandling-resumable-uploads': () => RemoveDanglingResumableUploadsScheduler.Instance.execute(), + 'process-video-views-buffer': () => VideoViewsBufferScheduler.Instance.execute(), + 'process-video-viewers': () => VideoViewsManager.Instance.processViewerStats() } + await processors[body.command]() + return res.status(HttpStatusCode.NO_CONTENT_204).end() }