aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 16:02:11 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit883a9019085ff9013079d6b1539b86f2f519175a (patch)
treebf1f68340ee4b482f880753bdd4658e91aff8335 /server
parenta9c58393d36d221197b48884a1960e6126ab31d7 (diff)
downloadPeerTube-883a9019085ff9013079d6b1539b86f2f519175a.tar.gz
PeerTube-883a9019085ff9013079d6b1539b86f2f519175a.tar.zst
PeerTube-883a9019085ff9013079d6b1539b86f2f519175a.zip
Introduce debug command
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/server/debug.ts6
-rw-r--r--server/helpers/database-utils.ts10
-rw-r--r--server/tests/api/videos/resumable-upload.ts5
3 files changed, 10 insertions, 11 deletions
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts
index a6e9147f3..31888e963 100644
--- a/server/controllers/api/server/debug.ts
+++ b/server/controllers/api/server/debug.ts
@@ -1,8 +1,8 @@
1import * as express from 'express'
1import { InboxManager } from '@server/lib/activitypub/inbox-manager' 2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
2import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' 3import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
4import { Debug, SendDebugCommand } from '@shared/models'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
4import { SendDebugCommand } from '@shared/models'
5import * as express from 'express'
6import { UserRight } from '../../../../shared/models/users' 6import { UserRight } from '../../../../shared/models/users'
7import { authenticate, ensureUserHasRight } from '../../../middlewares' 7import { authenticate, ensureUserHasRight } from '../../../middlewares'
8 8
@@ -32,7 +32,7 @@ function getDebug (req: express.Request, res: express.Response) {
32 return res.json({ 32 return res.json({
33 ip: req.ip, 33 ip: req.ip,
34 activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting() 34 activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
35 }) 35 } as Debug)
36} 36}
37 37
38async function runCommand (req: express.Request, res: express.Response) { 38async function runCommand (req: express.Request, res: express.Response) {
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index b5dc70c17..cbd7aa401 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -6,7 +6,7 @@ import { sequelizeTypescript } from '@server/initializers/database'
6import { logger } from './logger' 6import { logger } from './logger'
7 7
8function retryTransactionWrapper <T, A, B, C, D> ( 8function retryTransactionWrapper <T, A, B, C, D> (
9 functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise<T> | Bluebird<T>, 9 functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise<T>,
10 arg1: A, 10 arg1: A,
11 arg2: B, 11 arg2: B,
12 arg3: C, 12 arg3: C,
@@ -14,20 +14,20 @@ function retryTransactionWrapper <T, A, B, C, D> (
14): Promise<T> 14): Promise<T>
15 15
16function retryTransactionWrapper <T, A, B, C> ( 16function retryTransactionWrapper <T, A, B, C> (
17 functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T> | Bluebird<T>, 17 functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T>,
18 arg1: A, 18 arg1: A,
19 arg2: B, 19 arg2: B,
20 arg3: C 20 arg3: C
21): Promise<T> 21): Promise<T>
22 22
23function retryTransactionWrapper <T, A, B> ( 23function retryTransactionWrapper <T, A, B> (
24 functionToRetry: (arg1: A, arg2: B) => Promise<T> | Bluebird<T>, 24 functionToRetry: (arg1: A, arg2: B) => Promise<T>,
25 arg1: A, 25 arg1: A,
26 arg2: B 26 arg2: B
27): Promise<T> 27): Promise<T>
28 28
29function retryTransactionWrapper <T, A> ( 29function retryTransactionWrapper <T, A> (
30 functionToRetry: (arg1: A) => Promise<T> | Bluebird<T>, 30 functionToRetry: (arg1: A) => Promise<T>,
31 arg1: A 31 arg1: A
32): Promise<T> 32): Promise<T>
33 33
@@ -36,7 +36,7 @@ function retryTransactionWrapper <T> (
36): Promise<T> 36): Promise<T>
37 37
38function retryTransactionWrapper <T> ( 38function retryTransactionWrapper <T> (
39 functionToRetry: (...args: any[]) => Promise<T> | Bluebird<T>, 39 functionToRetry: (...args: any[]) => Promise<T>,
40 ...args: any[] 40 ...args: any[]
41): Promise<T> { 41): Promise<T> {
42 return transactionRetryer<T>(callback => { 42 return transactionRetryer<T>(callback => {
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 4fc3317df..6c01c7e78 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -12,7 +12,6 @@ import {
12 flushAndRunServer, 12 flushAndRunServer,
13 getMyUserInformation, 13 getMyUserInformation,
14 prepareResumableUpload, 14 prepareResumableUpload,
15 sendDebugCommand,
16 sendResumableChunks, 15 sendResumableChunks,
17 ServerInfo, 16 ServerInfo,
18 setAccessTokensToServers, 17 setAccessTokensToServers,
@@ -138,13 +137,13 @@ describe('Test resumable upload', function () {
138 }) 137 })
139 138
140 it('Should not delete recent uploads', async function () { 139 it('Should not delete recent uploads', async function () {
141 await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) 140 await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
142 141
143 expect(await countResumableUploads()).to.equal(2) 142 expect(await countResumableUploads()).to.equal(2)
144 }) 143 })
145 144
146 it('Should delete old uploads', async function () { 145 it('Should delete old uploads', async function () {
147 await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) 146 await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
148 147
149 expect(await countResumableUploads()).to.equal(0) 148 expect(await countResumableUploads()).to.equal(0)
150 }) 149 })